diff --git a/createFlutter b/createFlutter index 889564a..1a1d488 100755 --- a/createFlutter +++ b/createFlutter @@ -202,33 +202,39 @@ EOF ######################### cat > lib/main.dart < runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - title: '$appName', - theme: ThemeData( - primarySwatch: Colors.blue, - ), - home: MyHomePage(title: '$appName'), - ); - } +void main() { + runApp(MaterialApp( + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: Loading(), + )); } -class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); - final String title; +EOF + +#################################### +## create loading and home screen ## +#################################### + +mkdir lib/screens + +cat > lib/screens/home.dart < _MyHomePageState(); + _HomeState createState() => _HomeState(); } -class _MyHomePageState extends State { +class _HomeState extends State { int state = 1; - + void _changeState(int s) { setState(() { state = s; @@ -241,7 +247,7 @@ class _MyHomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(widget.title), + title: Text(Home.title), actions: [ PopupMenuButton( onSelected: (String value) => handleClick(context, value), @@ -268,10 +274,48 @@ class _MyHomePageState extends State { void handleClick(BuildContext context, String value) { switch (value) { case 'About': - showLicensePage(context: context, applicationName: widget.title); + showLicensePage(context: context, applicationName: Home.title); } } } + +EOF + + +cat > lib/screens/loading.dart < _LoadingState(); +} + +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(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea( + child: Text("Loading..."), + ), + ); + } +} + EOF