Flutter列表视图增强插件listview_ex的使用
Flutter列表视图增强插件listview_ex的使用
ListViewEx
是一个类似于 Flutter 框架中的 ListView
的组件。它具有相同的字段。所有你需要做的就是将 ListView
替换为 ListViewEx
,这样你就可以获得 header
和 footer
属性,它们只是普通的 Widget。
特性
开始使用
替换你的 ListView
为 ListViewEx
。
使用示例
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
[@override](/user/override)
Widget build(BuildContext context) {
const textStyle = TextStyle(fontSize: 20);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Material(
child: Container(
color: Colors.white,
child: ListViewEx(
// 头部
header: Container(
height: 60,
alignment: Alignment.center,
color: Colors.red,
child: const Text("Header", style: textStyle),
),
// 尾部
footer: Container(
height: 60,
alignment: Alignment.center,
color: Colors.blue,
child: const Text("Footer", style: textStyle),
),
// 列表项
children: List<int>.generate(100, (index) => index)
.map((e) => SizedBox(
height: 40, child: Text(e.toString(), style: textStyle)))
.toList(),
),
),
),
);
}
}
更多关于Flutter列表视图增强插件listview_ex的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复