我正在尝试为应用程序创建一个事件页面,用户可以在其中查看具有横幅图像和其他一些有用信息的事件。我真的很喜欢用横幅实现 SliverAppBar 的想法,以便用户可以滚动查看更多信息。为此,我似乎需要一个带有 SliverAppBar 和FlexibleSpaceBar 的 CustomScrollView 。
我在网上看到的所有教程都假设屏幕的其余部分应该是各种列表,但我更想要像“列”小部件之类的东西。但是,Column 的高度不受限制,这会导致 CustomScrollView 中出现溢出错误。我可以将它包装在指定高度的容器中,但是主体的内容是可变大小的,所以这并不理想。有没有办法让 SliverAppBar 和 Column 并排工作?
我想要类似这样的东西:
class ActivityPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(slivers: [
SliverAppBar(
flexibleSpace: FlexibleSpaceBar(
background: Image(someImage),
),
expandedHeight: Image,
floating: false,
pinned: true,
snap: false,
),
Column(
children: [
someChildren,
]
),
)
]),
),
);
}
Run Code Online (Sandbox Code Playgroud)
这应该是可能的,因为在我看来,这似乎是一种常见的模式,但我环顾四周,只能找到主体由列表组成的示例......
我看过很多关于这个问题的帖子,但没有一个答案适用于我的情况(我想我也知道为什么)。我的 Flutter 移动应用程序中有一个登录页面,用户可以在其中注册、登录或要求接收电子邮件以重置密码。对于每个功能,我都有一个Form小部件。每个表单都需要一个表单键 (a GlobalKey<FormState>)。用户可以通过IndexedStack. 在表单之间切换时收到的错误是:
The following assertion was thrown while finalizing the widget tree:
Multiple widgets used the same GlobalKey.
The key [LabeledGlobalKey<FormState>#eebb6] was used by multiple widgets. The parents of those widgets were different widgets that both had the following description:
RegisterPage(dependencies: [_LocalizationsScope-[GlobalKey#f7403], _InheritedProviderScope<LandingPageModel>, _InheritedTheme])
A GlobalKey can only be specified on one widget at a time in the widget tree.
Run Code Online (Sandbox Code Playgroud)
现在这个问题是类似的,但解决方案不起作用,因为我需要键的类型为 …