my_drawer.dart
unknown
plain_text
a month ago
1.3 kB
5
Indexable
import 'package:flutter/material.dart'; class MyDrawer extends StatelessWidget { const MyDrawer({super.key}); @override Widget build(BuildContext context) { return Drawer( // Add a ListView to the drawer. This ensures the user can scroll // through the options in the drawer if there isn't enough vertical // space to fit everything. child: ListView( // Important: Remove any padding from the ListView. padding: EdgeInsets.zero, children: [ const DrawerHeader( decoration: BoxDecoration( color: Colors.blue, ), child: Text('Drawer Header'), ), ListTile( title: const Text('First Screen'), onTap: () { // Update the state of the app. // ...copy paste the navigator.push method here //you may navigate to SecondScreen Navigator.pop(context); // Pop Drawer Navigator.pushNamed(context, '/'); }, ), ListTile( title: const Text('Second Screen'), onTap: () { Navigator.pop(context); // Pop Drawer Navigator.pushNamed(context, '/second'); // Update the state of the app. // ...copy paste here the navigator.push method }, ), ], ), ); } }
Editor is loading...
Leave a Comment