Advertisement
wemersonrv

Custom Drawer

Jul 8th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.07 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class HomeScreen extends StatelessWidget {
  4.   @override
  5.   Widget build(BuildContext context) {
  6.     return Scaffold(
  7.      appBar: AppBar(
  8.         title: "MaisSync",
  9.         centerTitle: true,
  10.       ),
  11.       drawer: CustomDrawer(),
  12.       body: Center(
  13.         child: DetailsWidget(),
  14.       ),
  15.     );
  16.   }
  17. }
  18.  
  19. class CustomDrawer extends StatelessWidget {
  20.   @override
  21.   Widget build(BuildContext context) {
  22.     return Drawer(
  23.       child: Column(
  24.         children: <Widget>[
  25.           DrawerHeader(
  26.             child: Image.asset(
  27.               "images/logo.png",
  28.               width: 180,
  29.             ),
  30.           ),
  31.           DrawerItem(
  32.             text: "Início",
  33.             icon: Icons.home,
  34.             onTap: () {
  35.               Navigator.of(context).push(
  36.                 MaterialPageRoute(builder: (context) => HomeScreen()),
  37.               );
  38.             },
  39.           ),
  40.           DrawerItem(
  41.             text: "Configurações",
  42.             icon: Icons.settings,
  43.             onTap: () {
  44.               Navigator.of(context).push(
  45.                 MaterialPageRoute(builder: (context) => SetupScreen()),
  46.               );
  47.             },
  48.           ),
  49.           DrawerItem(
  50.             text: "LOGs",
  51.             icon: Icons.insert_drive_file,
  52.             onTap: () {
  53.               Navigator.of(context).push(
  54.                 MaterialPageRoute(builder: (context) => LogScreen()),
  55.               );
  56.             },
  57.           ),
  58.         ],
  59.       ),
  60.     );
  61.   }
  62. }
  63.  
  64. class DrawerItem extends StatelessWidget {
  65.   final String text;
  66.   final IconData icon;
  67.   final Function onTap;
  68.  
  69.   const DrawerItem({
  70.     Key key,
  71.     this.text,
  72.     this.icon,
  73.     this.onTap,
  74.   }) : super(key: key);
  75.  
  76.   @override
  77.   Widget build(BuildContext context) {
  78.     return InkWell(
  79.       onTap: onTap,
  80.       child: ListTile(
  81.         leading: Icon(icon, color: Colors.grey[800]),
  82.         title: Text(
  83.           text,
  84.           style: TextStyle(
  85.             color: Colors.grey[800],
  86.           ),
  87.         ),
  88.       ),
  89.     );
  90.   }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement