Last active
December 3, 2021 14:26
-
-
Save kasperpeulen/028686bcb30a993edbbfae944b8c1ff8 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
import 'package:provider/provider.dart'; | |
enum Page { counter, settings } | |
class MyApp extends HookWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final currentPage = useState(Page.counter); | |
return MaterialApp( | |
home: Provider.value(value: currentPage, child: MyScaffold()), | |
); | |
} | |
} | |
ValueNotifier<Page> usePage() => useContext().watch<ValueNotifier<Page>>(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment