class Home extends StatelessWidget{
@override
Widget build(BuildContext context){
return new MediaQuery(
data: new MediaQueryData.fromWindow(ui.window),
child: new SafeArea(
child: new Material(
child: new CustomScrollView(
slivers: <Widget>[
new SliverPersistentHeader(
delegate: MyCustomAppBar(expandedHeight: 200),
pinned: true,
),
new SliverList(
delegate: SliverChildBuilderDelegate(
(_,index) => ListTile(
title: Text(
"Index: $index",
textDirection: TextDirection.ltr,
),
),
),
),
],
),
),
),
);
}
}
我正在创建一个自定义滚动视图,但我有错误,我不能理解它是从哪里生成的?
我正在使用SliverPersistentHeaderDelegate类创建自定义appBar。
1条答案
按热度按时间1u4esq0p1#
错误
表示
Widget build
需要Widget,但未返回有效Widget。如果Home类是main.dart中应用程序的入口点,那么在使用其他Widget之前,您可能需要先使用MaterialApp。