【发布时间】:2020-08-20 13:11:51
【问题描述】:
有没有办法通过使用 ListView 来记住和突出显示选定的 Drawer 项?
我在java navigationView.setItemBackgroundResource(R.drawable.colorselect); 中使用了这段代码,但是我不知道如何在flutter中做到这一点!
我尝试了一些方法但不起作用,当我选择一个项目时,所有其他项目的背景都改变了!
这是我的代码的样子
class AboutApp extends StatefulWidget {
@override
_AboutAppState createState() => _AboutAppState();
}
class _AboutAppState extends State<AboutApp> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Demo App'),
),
drawer: Drawer(
child: Center(
child: Column(children: <Widget>[
Expanded(
child: ListView(
shrinkWrap: true,
children: [
Container(
child: Text(
'Part1',
style: TextStyle(fontSize: 20),
),
color: Colors.blue,
height: 30,
),
ListTile(
onTap: () {},
title: Text('Item Part1'),
),
ListTile(
onTap: () {},
title: Text('Item Part1'),
),
Container(
child: Text(
'Part2',
style: TextStyle(fontSize: 20),
),
color: Colors.blue,
height: 30,
),
ListTile(
onTap: () {},
title: Text('Item Part2'),
),
ListTile(
onTap: () {},
title: Text('Item Part2'),
),
],
),
),
Container(
child: Text(
'this is footer',
style: TextStyle(fontSize: 20),
),
)
]),
),
),
);
}
}
.................................................. ............ ..................................................... ………… ..................................................... ........
【问题讨论】:
标签: flutter