GetX App Drawer Pattern
import "package:flutter/material.dart";
import "package:get/get.dart";
import "package:getx_flutter/CPPS_Application/cpps_EditPage.dart";
import "package:getx_flutter/CPPS_Application/cpps_ProfilePage.dart";
import "package:getx_flutter/CPPS_Application/cpps_controller.dart";
import "package:getx_flutter/CPPS_Application/cpps_GridView.dart";
import "package:getx_flutter/CPPS_Application/cpps_splash_screen.dart";
void main() {
runApp(const MyApp(),);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: "CPPS Application",
theme: ThemeData(
primarySwatch: Colors.brown,
),
home: const SplashCpps(),
);
}
}
class AppDrawer extends StatelessWidget {
AppDrawer({super.key});
CppsController cpControl = Get.put(CppsController(),);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("CPPS"),
centerTitle: true,
),
drawer: Drawer(
child: Column(
children: [
UserAccountsDrawerHeader(
accountName: const Text("Kaushik Parmar", style: TextStyle(fontWeight: FontWeight.bold,),),
accountEmail: const Text("9879737681", style: TextStyle(fontWeight: FontWeight.bold,),),
currentAccountPicture: InkWell(
onTap: () { Get.to(() { return HeroCpps(); },); },
child: const Hero(
tag: "hanuman",
child: CircleAvatar(
backgroundImage: AssetImage("assets/images/Lord-Hanuman.jpg"),
),
),
),
otherAccountsPictures: [
InkWell(
onTap: () {
Get.to(() { return HeroCpps(); },);
},
child: const Icon(Icons.account_circle, color: Colors.white,),
),
InkWell(
onTap: () {
Get.to(() { return EditCpps(); },);
},
child: const Icon(Icons.logout, color: Colors.white,),
),
],
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/Natural_image.jpg"),
//fit: BoxFit.cover,
),
),
),
Flexible(
fit: FlexFit.tight,
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView.builder(
shrinkWrap: true,
itemCount: cpControl.iconList.length,
itemBuilder: (context, index) {
return Container(
decoration: const BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.black26),),
),
child: ListTile(
dense: true,
// contentPadding: EdgeInsets.symmetric(horizontal: 0.0, vertical: 0.0,),
visualDensity: const VisualDensity(vertical: -2.0, horizontal: 0.0,),
horizontalTitleGap: 0.0,
minVerticalPadding: 0.0,
leading: Icon(cpControl.iconList[index], color: Colors.black,),
title: Text("${cpControl.titleList[index]}", style: const TextStyle(fontSize: 20.0,), maxLines: 1,),
subtitle: Text("${cpControl.subtitleList[index]}", maxLines: 1,),
onTap: () { Get.back(); },
),
);
},
),
),
),
const Divider(thickness: 3, color: Colors.black,),
],
),
),
body: Center(
child: GridCpps(),
),
);
}
}
import "package:flutter/material.dart";
import "package:get/get.dart";
import 'package:getx_flutter/CodeX/views/shopping_page.dart';
class GridCpps extends StatelessWidget {
GridCpps({super.key});
List<Branches> myGridList = [
Branches(title: 'Home', icon: Icons.home,),
Branches(title: 'Contact', icon: Icons.contacts,),
Branches(title: "Map", icon: Icons.map,),
Branches(title: "Phone", icon: Icons.phone,),
Branches(title: "Camera", icon: Icons.camera_alt,),
Branches(title: "Setting", icon: Icons.settings,),
Branches(title: "Album", icon: Icons.photo_album,),
Branches(title: "WiFi", icon: Icons.wifi,),
];
List<Widget> routes = [
ShoppingPage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: GridView.builder(
// shrinkWrap: true,
itemCount: myGridList.length,
itemBuilder: (context, index) {
return Card(
child: Container(
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(10.0,),
),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(myGridList[index].icon),
const SizedBox(height: 10.0,),
Text("${myGridList[index].title.toString()}"),
],
),
),
),
);
},
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 12.0,
mainAxisSpacing: 12.0,
),
),
),
),
);
}
}
class Branches {
Branches({required this.title, required this.icon});
String title;
// IconData icon;
var icon;
}
Comments
Post a Comment