Created
October 23, 2020 20:22
-
-
Save cerberodev/ccd5a1927cc0f1ee826ac53443c40fae to your computer and use it in GitHub Desktop.
Open End Drawer in Flutter - Cambiar nombre al archivo como main.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///Cambiar nombre al archivo como main.dart | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); | |
void _openEndDrawer() { | |
_scaffoldKey.currentState.openEndDrawer(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
key: _scaffoldKey, | |
appBar: AppBar( | |
title: Text('Drawer Demo'), | |
actions: [ | |
IconButton(icon: Icon(Icons.person), onPressed: _openEndDrawer) | |
], | |
), | |
body: Center( | |
child: ElevatedButton( | |
onPressed: _openEndDrawer, | |
child: Text('Open End Drawer'), | |
), | |
), | |
endDrawer: Drawer( | |
child: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
const Text('This is the Drawer'), | |
ElevatedButton( | |
onPressed: () {}, | |
child: const Text('Close Drawer'), | |
), | |
], | |
), | |
), | |
), | |
// Disable opening the end drawer with a swipe gesture. | |
endDrawerEnableOpenDragGesture: false, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment