easy_sidemenu 0.1.1+1 easy_sidemenu: ^0.1.1+1 copied to clipboard
An easy to use side menu in flutter and can used for navigations
import 'package:flutter/material.dart';
import 'package:easy_sidemenu/easy_sidemenu.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'easy_sidemenu Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'easy_sidemenu Demo'),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
PageController page = PageController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
centerTitle: true,
),
body: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SideMenu(
controller: page,
style: SideMenuStyle(
displayMode: SideMenuDisplayMode.auto,
hoverColor: Colors.blue[100],
selectedColor: Colors.lightBlue,
selectedTitleTextStyle: TextStyle(color: Colors.white),
selectedIconColor: Colors.white,
// backgroundColor: Colors.amber
// openSideMenuWidth: 200
),
title: Column(
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 150,
maxWidth: 150,
),
child: Image.asset(
'assets/images/easy_sidemenu.png',
),
),
Divider(
indent: 8.0,
endIndent: 8.0,
),
],
),
footer: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'mohada',
style: TextStyle(fontSize: 15),
),
),
items: [
SideMenuItem(
priority: 0,
title: 'Dashboard',
onTap: () {
page.jumpToPage(0);
},
icon: Icons.home,
),
SideMenuItem(
priority: 1,
title: 'Users',
onTap: () {
page.jumpToPage(1);
},
icon: Icons.supervisor_account,
),
SideMenuItem(
priority: 2,
title: 'Files',
onTap: () {
page.jumpToPage(2);
},
icon: Icons.file_copy_rounded,
),
SideMenuItem(
priority: 3,
title: 'Download',
onTap: () {
page.jumpToPage(3);
},
icon: Icons.download,
),
SideMenuItem(
priority: 4,
title: 'Settings',
onTap: () {
page.jumpToPage(4);
},
icon: Icons.settings,
),
SideMenuItem(
priority: 6,
title: 'Exit',
onTap: () async {},
icon: Icons.exit_to_app,
),
],
),
Expanded(
child: PageView(
controller: page,
children: [
Container(
color: Colors.white,
child: Center(
child: Text(
'Page\n 1',
style: TextStyle(fontSize: 35),
),
),
),
Container(
color: Colors.white,
child: Center(
child: Text(
'Page\n 2',
style: TextStyle(fontSize: 35),
),
),
),
Container(
color: Colors.white,
child: Center(
child: Text(
'Page\n 3',
style: TextStyle(fontSize: 35),
),
),
),
Container(
color: Colors.white,
child: Center(
child: Text(
'Page\n 4',
style: TextStyle(fontSize: 35),
),
),
),
Container(
color: Colors.white,
child: Center(
child: Text(
'Page\n 5',
style: TextStyle(fontSize: 35),
),
),
),
],
),
),
],
),
);
}
}