From 9cc63a365b3ef279f666526cd4f070cd47de5475 Mon Sep 17 00:00:00 2001 From: gutmet Date: Fri, 22 May 2020 19:32:17 +0200 Subject: [PATCH] let the home widget load for itself (don't separate loading and saving) --- createFlutter | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/createFlutter b/createFlutter index 1a1d488..23b4dac 100755 --- a/createFlutter +++ b/createFlutter @@ -228,6 +228,20 @@ class Home extends StatefulWidget { Home({Key key}) : super(key: key); static const title = '$appName'; + static void loadInitial(BuildContext context) async { + await Future.delayed(Duration.zero, () {}); + // load some stuff here and await results + Navigator.pushReplacement(context, + MaterialPageRoute(builder: (context) => Home())); + } + + static void save(BuildContext context) async { + showDialog(context: context, barrierDismissible: false, + builder: (BuildContext context) { return AlertDialog(content: Text("Saving...")); }); + await Future.delayed(Duration.zero, () {}); + Navigator.of(context, rootNavigator: true).pop(); + } + @override _HomeState createState() => _HomeState(); } @@ -293,17 +307,10 @@ class Loading extends StatefulWidget { } class _LoadingState extends State { - void load() async { - await Future.delayed(Duration.zero, () {}); - // load some stuff here and await results - Navigator.pushReplacement(context, - MaterialPageRoute(builder: (context) => Home())); - } - @override void initState() { super.initState(); - load(); + Home.loadInitial(context); } @override