together_mobile/lib/main.dart

48 lines
1.3 KiB
Dart
Raw Normal View History

2023-06-21 17:44:28 +08:00
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
2023-06-21 17:44:28 +08:00
import 'package:together_mobile/common/theme.dart';
2023-08-11 23:02:31 +08:00
import 'package:together_mobile/database/hive_database.dart';
2023-06-21 17:44:28 +08:00
import 'package:together_mobile/router/router.dart';
import 'package:together_mobile/models/init_get_it.dart';
2023-09-09 16:48:47 +08:00
import 'notification_api.dart';
2023-06-21 17:44:28 +08:00
final easyLoading = EasyLoading.init();
2023-09-09 16:48:47 +08:00
void main() async {
initGetIt();
2023-09-10 11:30:20 +08:00
await NotificationAPI.init();
HiveDatabase.registerAdapter();
2023-06-21 17:44:28 +08:00
runApp(const Together());
}
class Together extends StatelessWidget {
const Together({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
title: "Together",
theme: lightThemeData(context),
darkTheme: darkThemeData(context),
routerConfig: router,
// This builder is used to dismiss keyboard while tap anywhere of the
// screen excluding the input widgets.
builder: (context, child) {
child = easyLoading(context, child);
child = GestureDetector(
2023-09-10 11:30:20 +08:00
onTap: () {
if (FocusManager.instance.primaryFocus != null) {
FocusManager.instance.primaryFocus!.unfocus();
}
},
2023-06-21 17:44:28 +08:00
child: child,
);
return child;
2023-06-21 17:44:28 +08:00
},
);
}
}