together_mobile/lib/main.dart

50 lines
1.3 KiB
Dart
Raw Permalink Normal View History

2023-06-21 17:44:28 +08:00
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
2024-04-11 17:27:45 +08:00
import 'package:together_mobile/utils/env.dart';
2024-04-09 17:23:28 +08:00
import '/common/theme.dart';
import '/database/hive_database.dart';
import '/router/router.dart';
import '/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 {
2024-04-11 17:27:45 +08:00
await EnvConfig.loadEnv(Env.product);
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
},
);
}
}