Skip to content

Instantly share code, notes, and snippets.

@gokulsundar188
Last active August 19, 2020 07:00
Show Gist options
  • Save gokulsundar188/1395d654a7c79946c2b80b1187c554fb to your computer and use it in GitHub Desktop.
Save gokulsundar188/1395d654a7c79946c2b80b1187c554fb to your computer and use it in GitHub Desktop.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<SideMenu> _dynamicListMenu = SideMenu.getSideMenu();
int _counter = 0;
var isMenuSelected;
var selectedTabTemp;
var selectedTab;
bool isLogin = false;
Color colorMenuItem = Colors.white;
double height;
double width;
@override
void initState() {
// TODO: implement initState
super.initState();
selectedTab = _dynamicListMenu[0].name;
}
@override
Widget build(BuildContext context) {
height = MediaQuery.of(context).size.height - 25;
width = MediaQuery.of(context).size.width;
return SafeArea(
child: Scaffold(
body: Center(child: menuListCopy()),
));
}
Widget menuListCopy() {
return Container(
height: double.infinity,
width: double.infinity,
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1, childAspectRatio: width / (height / 9)),
itemCount: _dynamicListMenu.length,
physics: ClampingScrollPhysics(),
itemBuilder: (context, index) {
return Container(
color: index % 2 == 0 ? Colors.blue : Colors.blueAccent,
alignment: Alignment.topCenter,
child: GridTile(
child: InkWell(
onTap: () {
setState(() {});
},
child: Visibility(
visible: _dynamicListMenu[index].name == "Funds"
? (isLogin ? true : false)
: true,
child: AspectRatio(
aspectRatio: width / (height / 9),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_dynamicListMenu[index].id != 8
? Icon(
IconData(
_dynamicListMenu[index].icon,
fontFamily: 'AppIcons'),
color: colorMenuItem,
size: 20)
: Icon(Icons.language,
color: colorMenuItem, size: 20),
SizedBox(height: 5),
Text(
_dynamicListMenu[index]
.name
.toUpperCase(),
textAlign: TextAlign.center,
maxLines: 1,
)
])),
))));
}));
}
}
class SideMenu {
int id;
int icon;
String name;
bool selected;
SideMenu(this.id, this.icon, this.name, this.selected);
static List<SideMenu> getSideMenu() {
return [
new SideMenu(1, 0xe91f, "Home", false),
new SideMenu(2, 0xe911, "Funds", false),
new SideMenu(3, 0xe94f, "Games", false),
new SideMenu(4, 0xe900, "Contact Us", false),
new SideMenu(5, 0xe91c, "Promo", false),
new SideMenu(6, 0xe922, "Info", false),
new SideMenu(7, 0xe94e, "Referral", false),
new SideMenu(8, 0xe912, "Language", false),
new SideMenu(9, 0xe916, "Collapse", false),
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment