aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgutmet <me.git@gutmet.org>2020-05-22 19:32:17 +0200
committergutmet <me.git@gutmet.org>2020-05-22 19:32:17 +0200
commit9cc63a365b3ef279f666526cd4f070cd47de5475 (patch)
treeec0196a7b56a3d0b5f30922c24908fe14da0fc95
parent0bd793e0e202f3e3d8ce81965e3e2c21a74c887b (diff)
downloadsnippets-9cc63a365b3ef279f666526cd4f070cd47de5475.tar.gz
let the home widget load for itself (don't separate loading and saving)
-rwxr-xr-xcreateFlutter23
1 files 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<Loading> {
- 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