I have solved the previous issue based on an existing solution to existing question.
I am still facing problem in creating a Stateful Widget for the Drawer.
Here is Github link to project: https://github.com/Aaklii/flutter_app
drawer: buildDrawer(context),
I want to give more features to drawer item in a later stage so I want to create a Stateful Widget but this code is not working:
class ListDrawer extends StatefulWidget {
List<ListClass> listOjects;
ListDrawer({this.listOjects});
@override
_ListDrawerState createState() => _ListDrawerState();
}
class _ListDrawerState extends State<ListDrawer> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Column(
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.all(20),
child: ListView.builder(
itemCount: widget.listOjects.length,
itemBuilder: (context, index) {
return CustomListTile(
listObject: widget.listOjects[index],
// isSelected:
// selectedIndex != null && selectedIndex == index
// ? true
// : false,
index: index,
);
},
),
),
)
],
),
);
}
}
So I am currently using buildDrawer()
Drawer buildDrawer(BuildContext context) {
return Drawer(
child: SafeArea(
child: Column(
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.all(20),
child: ListView.builder(
itemCount: listOjects.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
setState(() {
onSelected(index);
});
Navigator.of(context).pop();
},
child: CustomListTile(
listObject: listOjects[index],
isSelected:
selectedIndex != null && selectedIndex == index
? true
: false,
index: index,
),
);
},
),
),
)
],
),
),
);
}