lemmur-app-android/lib/main.dart

91 lines
2.2 KiB
Dart
Raw Normal View History

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';
2020-09-01 13:22:37 +02:00
import 'stores/accounts_store.dart';
2020-08-30 22:43:16 +02:00
import 'stores/config_store.dart';
2020-08-02 13:34:42 +02:00
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
var configStore = ConfigStore();
await configStore.load();
2020-09-01 13:22:37 +02:00
var accountsStore = AccountsStore();
await accountsStore.load();
2020-08-30 22:43:16 +02:00
runApp(
MultiProvider(
providers: [
Provider<ConfigStore>(
create: (_) => configStore,
2020-08-30 22:43:16 +02:00
dispose: (_, store) => store.dispose(),
),
2020-09-01 13:22:37 +02:00
Provider<AccountsStore>(
create: (_) => accountsStore,
dispose: (_, store) => store.dispose(),
),
2020-08-30 22:43:16 +02:00
],
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(
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
}