From cb7b65f2e324bbf829a8956752b82b5f99e673fe Mon Sep 17 00:00:00 2001 From: gutmet Date: Thu, 21 May 2020 16:18:49 +0200 Subject: [PATCH] createFlutter: overwrite useless main.dart --- createFlutter | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/createFlutter b/createFlutter index 5fd434b..623db06 100755 --- a/createFlutter +++ b/createFlutter @@ -274,6 +274,84 @@ $description EOF +######################### +## overwrite main.dart ## +######################### +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'), + ); + } +} + +class MyHomePage extends StatefulWidget { + MyHomePage({Key key, this.title}) : super(key: key); + final String title; + + @override + _MyHomePageState createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int state = 1; + + void _changeState(int s) { + setState(() { + state = s; + }); + } + + List popupMenuItems = ["About"]; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(widget.title), + actions: [ + PopupMenuButton( + onSelected: (String value) => handleClick(context, value), + itemBuilder: (BuildContext context) { + return popupMenuItems.map((String choice) { + return PopupMenuItem( + value: choice, + child: Text(choice), + ); + }).toList(); + }, + ), + ], + ), + body: Padding( + padding: const EdgeInsets.all(8.0), + child: ListView(children: [ + Text("Lorem ipsum dolor sit amet"), + ]), + ), + ); + } + + void handleClick(BuildContext context, String value) { + switch (value) { + case 'About': + showLicensePage(context: context, applicationName: widget.title); + } + } +} +EOF + + ##################### ## create Makefile ## #####################