Files
Tanami_App/lib/main.dart
2024-07-05 15:36:29 +05:30

100 lines
3.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:local_auth/local_auth.dart';
import 'core/routes/routes.dart';
import 'core/utils/connectivity/network_connectivity.dart';
import 'features/biometric/presentation/bloc/biometric_bloc.dart';
import 'features/biometric/presentation/bloc/biometric_event.dart';
import 'features/countrySelection/presentation/bloc/choose_country_bloc.dart';
import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
/// The main function that runs the application.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// FlutterError.onError = (FlutterErrorDetails details) {
// FlutterError.dumpErrorToConsole(details);
// runApp(CustomErrorWidget(
// errorMessage: details.toString(),
// ));
// };
// Set the preferred orientations of the device.
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]).then((value) => runApp(const MyApp()
// StatsFl(
// isEnabled: true, //Toggle on/off
// width: 200, //Set size
// height: 50, //
// maxFps: 60, // Support custom FPS target (default is 60)
// showText: true, // Hide text label
// sampleTime: .5, //Interval between fps calculations, in seconds.
// totalTime: 15, //Total length of timeline, in seconds.
// align: Alignment.center, //Alignment of statsbox
// child: const MyApp())
));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
final NetworkConnectivity _networkConnectivity =
NetworkConnectivity(onStatusChange: (_) {});
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
// Initialize the NetworkConnectivity instance.
_networkConnectivity.initialize();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_networkConnectivity.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider(
create: (context) => RadioBloc(),
),
BlocProvider(
create: (_) => BottomNavigationBloc(),
),
BlocProvider(
create: (_) =>
BiometricBloc(LocalAuthentication())..add(CheckBiometricEvent()),
)
],
child: ScreenUtilInit(
builder: (BuildContext context, Widget? child) => MaterialApp.router(
title: 'Tanami Capital',
theme: ThemeData(
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
routerConfig: goRouter,
),
designSize: const Size(390, 844),
),
);
}
}