问题标签 [flutter-scaffold]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1551 浏览

flutter - 在 Flutter 中嵌套 Scaffold 是否正确?

我的应用主页中有一个 PageView,我想要:

  1. AppBar根据页面变化
  2. BottomAppBar 是固定的

我想象的两个解决方案是:

  1. 难点:拥有一个带有 appBar、body 和 bottomNavigationBar 的 Scaffold;使用 PageView 的 PageController 为 AppBar 内容设置动画...
  2. 有 2 个嵌套的 Scaffold:主要的一个带有 body 和 bottomNavigationBar,第二个在每个 PageView 的页面中,带有 AppBar...

所以我想知道,它可以工作,但是在语法上嵌套 Scaffold 是否“正确”?

非常感谢 !

0 投票
0 回答
82 浏览

flutter - 小部件树中的提供者 - MaterialApp 和 Scaffold 之间的范围?

我正在使用 Flutter 构建一个测验应用程序,并依靠提供者来更新 UI。我的小部件树有两个主要分支。一个与菜单和另一个游戏循环有关。

目前,我正在为与游戏循环相关的屏幕/分支使用 Multiprovider。我宁愿避免在 MaterialApp 级别(即小部件树的最顶部)使用提供程序。但是,我在游戏循环的某些消费者上收到错误消息。我认为范围可能是问题的根源。

是否有任何小部件可以将我的游戏循环(由多个屏幕/支架组成)封装在材料应用程序下方?或者在使用提供程序时在 Scaffold 和 MaterialApp 之间进行包装的另一种方式?

0 投票
2 回答
4923 浏览

flutter - 如何在Appbar左侧创建按钮[flutter]

我试图在应用栏左侧制作按钮[弹出新屏幕],但我发现只有抽屉不是我想要的。

我在 AppBar 中想要什么:

我现在拥有的:

0 投票
2 回答
183 浏览

flutter - Flutter: Persist BottomNavigationBar and route user to the correct screen depending on the selected index of the BottomNavigationBar

I want the BottomNavigationBar to persist and the user to be sent to a different screen depending on which index that they have selected and that index highlighted on the BottomNavigationBar.

The way I'm attempting to do this is to change the body value of the Scaffold according to the currently selected index of the BottomNavigationBar(). I am able to highlight the selected index of the BottomNavigationBar() once it is selected but the body is not routing to the appropriate widget.

The current method referenced for onTap: in the BottomNavBar correctly highlights the selected index but does not route to the correct widget.

There is an unused method (_switchScreen) in my BottomNavBar. Inserting this as the value to onTap: for the BottomNavBar() appropriately routes to the correct screen but then I have to have the BottomNavBar rebuilt on every view and is inaccessible behind the BottomNavBar which is referenced in the NavModel (Navigation Model).

Here is my BottomNavBar():

Here is the NavModel:

0 投票
1 回答
82 浏览

flutter - 在屏幕键盘上打开时让小部件移动到屏幕“上方”

我正在尝试使用 Flutter 的登录页面。目前它看起来像这样:

打开键盘之前

当我尝试使用屏幕键盘输入其中一个文本字段时,颤动会尝试将我的所有内容向上移动,直到显示“TEST”的图像到达顶部并且底部内容溢出:

打开键盘后

我见过的其他应用程序允许内容继续在屏幕“上方”移动,并且不会在顶部小部件到达屏幕顶部时停止。

我知道我可以通过设置为 false 来禁用脚手架中这些小部件的大小调整和移动,resizeToAvoidBottomInset但这看起来并不太好,并且会根据键盘覆盖不同的数量,所以我宁愿不这样做。

我怎样才能让小部件继续向上移动?此外,是否有办法阻止“创建帐户”小部件像其他小部件一样移动并将其保留在键盘下方?我试过查看颤振的文档,但我真的不知道如何描述这个问题以获得有用的结果,因为我对颤振还是很陌生。

“创建帐户”按钮固定在屏幕底部的单独列中,其余小部件位于包含另一列的展开小部件中。这两列都被父列包围。这是我的小部件树,以防它有用:

如果有人可以提供帮助,将不胜感激。

0 投票
1 回答
186 浏览

flutter - 如何使用底部导航栏从脚手架主体内部推送路线?

我在 Nav() 小部件中的 main.dart 中有一个 MaterialApp,它包含一个带有 appBar 和 BottomNavigationBar 的脚手架。NavigationBar 有 4 个 BottomNavigationBarItems,但我的整个应用程序中的页面数超过了 4 个。其他页面可以通过第一个 BottomNavigationBarItem 'Home' 访问。但是当我推送新的 NamedRoute 时,AppBar 消失了。我怎么解决这个问题?

我已经尝试在我自己的小部件中的新文件中使用底部导航栏。问题: setState() 不起作用。

这是一些代码

主要飞镖:

导航飞镖

home.dart:

myCard.dart:

我也愿意接受提示和技巧来改进我的代码。

编辑 - 新的 main.dart:

0 投票
1 回答
32 浏览

flutter - Flutter How to Scaffold layout size(错误)

我还在努力学习 Flutter。

我的主页上有一个按钮,它导航到我的 CustomWidget。(顺便说一句,它是 StepperWidget)

每当我尝试在我的小部件中添加脚手架时,它都会中断。在此处输入图像描述

并给出这个错误信息。这是我的小部件树 Scaffold --> Container (height and widht) --> SingleChildScrollView ---> Stepper with steps。

我试图拆除脚手架。但这一次,每当我单击 textformfield 时,就会出现底部溢出错误。提前致谢.. //

这是我的代码;

0 投票
0 回答
26 浏览

flutter - 在使用 Scaffold.of(context) 的方法中无法从网络请求中获取数据

我的Stateful小部件中有两个类方法。如您所见,在另一种方法中调用了一种方法

一级方法

二级方法

正如我在第二类方法中指出的那样,我在第二类方法中调用了第一类方法。

但是在第二类方法中调用第一类方法会给我以下错误,

我知道这与我Scaffold.of(context)在第二类方法中调用有关。我不知道如何解决这个问题。(我也遇到过人们提到传递脚手架密钥的帖子。我尝试过但没有用。我认为我可能错误地传递了脚手架密钥)

你能帮我解决这个问题吗?