createFlutter: overwrite useless main.dart
This commit is contained in:
parent
5c128f6f50
commit
cb7b65f2e3
|
@ -274,6 +274,84 @@ $description
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
#########################
|
||||||
|
## overwrite main.dart ##
|
||||||
|
#########################
|
||||||
|
cat > lib/main.dart <<EOF
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
void main() => 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<MyHomePage> {
|
||||||
|
int state = 1;
|
||||||
|
|
||||||
|
void _changeState(int s) {
|
||||||
|
setState(() {
|
||||||
|
state = s;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> popupMenuItems = ["About"];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(widget.title),
|
||||||
|
actions: <Widget>[
|
||||||
|
PopupMenuButton<String>(
|
||||||
|
onSelected: (String value) => handleClick(context, value),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return popupMenuItems.map((String choice) {
|
||||||
|
return PopupMenuItem<String>(
|
||||||
|
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 ##
|
## create Makefile ##
|
||||||
#####################
|
#####################
|
||||||
|
|
Loading…
Reference in New Issue
Block a user