Closed legacyO7 closed 3 years ago
Yes, You can use custom widget with upgraded version (i.e. drawerbehavior: ^1.0.3).
Code will be looks like:
return new DrawerScaffold(
appBar: AppBar(),
drawers: [
SideDrawer(
itemBuilder: (BuildContext context, MenuItem menuItem, bool isSelected) {
return Column(
children: [
Container(
// color: isSelected? getThemeColor().withOpacity(0.7): Colors.transparent,
padding: EdgeInsets.fromLTRB(24, 16, 24, 16),
child: Text(
menuItem.title,
style: Theme.of(context).textTheme.subtitle1.copyWith(
color: isSelected ? Colors.white : Colors.red,
fontWeight: FontWeight.bold,
fontSize: 16
),
// style: TextStyle(color: isSelected ? Colors.white : Colors.red, fontSize: 18),
),
),
(menuItem.id != 9) ? Divider(height: 2, color: Colors.white) : Container(),
],
);
},
degree: null,
elevation: 0.0,
percentage: 1,
cornerRadius: 0,
menu: menu,
direction: Direction.left,
animation: false,
alignment: Alignment.topLeft,
color: getThemeColor(),
selectorColor: Colors.white,
selectedItemId: selectedMenuItemId,
onMenuItemSelected: (itemId) {
setState(() {
selectedMenuItemId = itemId;
});
// Do whatever you want
if (itemId == 1) {
//Navigator.pushReplacementNamed(context, "/login");
}
else if(itemId == 2){
}
else{
}
},
)
],
builder: (context, constraint) => HomeView(),
I hope this will help you.
Yes, You can use custom widget with upgraded version (i.e. drawerbehavior: ^1.0.3).
Code will be looks like:
return new DrawerScaffold( appBar: AppBar(), drawers: [ SideDrawer( itemBuilder: (BuildContext context, MenuItem menuItem, bool isSelected) { return Column( children: [ Container( // color: isSelected? getThemeColor().withOpacity(0.7): Colors.transparent, padding: EdgeInsets.fromLTRB(24, 16, 24, 16), child: Text( menuItem.title, style: Theme.of(context).textTheme.subtitle1.copyWith( color: isSelected ? Colors.white : Colors.red, fontWeight: FontWeight.bold, fontSize: 16 ), // style: TextStyle(color: isSelected ? Colors.white : Colors.red, fontSize: 18), ), ), (menuItem.id != 9) ? Divider(height: 2, color: Colors.white) : Container(), ], ); }, degree: null, elevation: 0.0, percentage: 1, cornerRadius: 0, menu: menu, direction: Direction.left, animation: false, alignment: Alignment.topLeft, color: getThemeColor(), selectorColor: Colors.white, selectedItemId: selectedMenuItemId, onMenuItemSelected: (itemId) { setState(() { selectedMenuItemId = itemId; }); // Do whatever you want if (itemId == 1) { //Navigator.pushReplacementNamed(context, "/login"); } else if(itemId == 2){ } else{ } }, ) ], builder: (context, constraint) => HomeView(),
I hope this will help you.
This is giving me the following issue:
The following _TypeError was thrown building DrawerScaffoldMenuController(dirty, state: DrawerScaffoldMenuControllerState#20194):
type 'InkWell' is not a subtype of type '_MenuListItem'
I really can't understand why I got this problem
@Azzeccagarbugli As I'm seeing with your log, this issue occurs due to 'InkWell' widget. please check it.
is it possible to add divider between menuitems?