Created
December 3, 2021 14:27
-
-
Save kasperpeulen/fe69d9f3c53302cf041f8a36d31fb506 to your computer and use it in GitHub Desktop.
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
class MyScaffold extends HookWidget { | |
const MyScaffold({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final theme = useTheme(); | |
final currentPage = usePage(); | |
final count = useState(0); | |
final navigator = Navigator.of(context); | |
return Scaffold( | |
appBar: AppBar(title: Text('Title')), | |
body: Center(child: Text('Count: ${count.value}')), | |
drawer: Drawer( | |
child: ListView( | |
padding: EdgeInsets.zero, | |
children: [ | |
DrawerHeader( | |
decoration: BoxDecoration(color: theme.primaryColor), | |
child: Text( | |
'Drawer Header', | |
style: theme.primaryTextTheme.headline5, | |
), | |
), | |
ListTile( | |
selected: currentPage.value == Page.counter, | |
leading: Icon(Icons.message, color: Colors.blue), | |
title: Text('counter'), | |
onTap: () { | |
navigator.pop(); | |
currentPage.value = Page.counter; | |
}, | |
), | |
ListTile( | |
selected: currentPage.value == Page.settings, | |
leading: Icon(Icons.settings, color: Colors.red), | |
title: Text('Setings'), | |
onTap: () { | |
navigator.pop(); | |
currentPage.value = Page.settings; | |
}, | |
), | |
], | |
), | |
), //, | |
floatingActionButton: FloatingActionButton( | |
onPressed: () => count.value += 1, | |
child: Icon(Icons.add), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment