我想在应用栏下添加一行,如图二所示。
我怎样才能使这条线 flutter ?
图一是现在的应用程序,图二是 sliverAppBar 下的线
*已经尝试使用容器和分隔器
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: SvgPicture.asset(
'assets/icons/home_icon.svg',
color: Colors.black,
),
onPressed: () {}
),
actions: [
IconButton(
icon: SvgPicture.asset(
'assets/icons/search_icon.svg',
color: Colors.black,
),
onPressed: () {
}
),
IconButton(
icon: SvgPicture.asset(
'assets/icons/shopping_bag_icon.svg',
color: Colors.black,
),
onPressed: () {},
),
IconButton(
icon: SvgPicture.asset(
'assets/icons/profile_icon.svg',
color: Colors.black,
),
onPressed: () {}
),
],
floating: true,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Item #$index')),
childCount: 1000,
),
),
],
),
);
}
}
堆栈中的更多 txt 内容验证了我的问题
最佳答案
SliverAppBar Widget 中有一个“bottom”属性,它采用首选大小的 Widget,您可以为其指定以下属性:
bottom: PreferredSize(
preferredSize: Size(double.infinity, 5),
child: Divider(color: Colors.black),
),
关于flutter - 如何在 flutter 中的 SliverAppBar 下创建一条线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64188548/