2020-08-02 13:34:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2020-08-30 22:43:16 +02:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import 'stores/config_store.dart';
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-08-31 17:52:16 +02:00
|
|
|
Future<void> main() async {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
var configStore = ConfigStore();
|
|
|
|
await configStore.load();
|
|
|
|
|
2020-08-30 22:43:16 +02:00
|
|
|
runApp(
|
|
|
|
MultiProvider(
|
|
|
|
providers: [
|
|
|
|
Provider<ConfigStore>(
|
2020-08-31 17:52:16 +02:00
|
|
|
create: (_) => configStore,
|
2020-08-30 22:43:16 +02:00
|
|
|
dispose: (_, store) => store.dispose(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
child: MyApp(),
|
|
|
|
),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
2020-08-31 16:19:44 +02:00
|
|
|
Widget build(BuildContext context) => Observer(
|
|
|
|
builder: (ctx) => MaterialApp(
|
2020-08-30 22:43:16 +02:00
|
|
|
title: 'Flutter Demo',
|
|
|
|
themeMode: ctx.watch<ConfigStore>().theme,
|
|
|
|
darkTheme: ThemeData.dark(),
|
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: ctx.watch<ConfigStore>().accentColor,
|
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
|
),
|
2020-08-31 22:30:11 +02:00
|
|
|
home: MyHomePage(title: 'Flutter hello world'),
|
2020-08-31 16:19:44 +02:00
|
|
|
),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 _counter = 0;
|
|
|
|
|
|
|
|
void _incrementCounter() {
|
|
|
|
setState(() {
|
|
|
|
_counter++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2020-08-21 02:37:51 +02:00
|
|
|
Widget build(BuildContext context) => Scaffold(
|
2020-08-31 12:05:45 +02:00
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
|
|
|
body: Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
Text('You have pushed the button this many times:'),
|
|
|
|
Text(
|
|
|
|
'$_counter',
|
|
|
|
style: Theme.of(context).textTheme.headline4,
|
|
|
|
),
|
|
|
|
],
|
2020-08-21 02:37:51 +02:00
|
|
|
),
|
2020-08-31 12:05:45 +02:00
|
|
|
),
|
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
onPressed: _incrementCounter,
|
|
|
|
tooltip: 'Increment',
|
|
|
|
child: Icon(Icons.add),
|
|
|
|
),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|