130 lines
4.2 KiB
Dart
130 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.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 'core/utils/language/localizations_delegate.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';
|
|
import 'shared/components/bloc/language/lng_bloc.dart';
|
|
import 'shared/components/bloc/language/lng_state.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()),
|
|
),
|
|
BlocProvider(
|
|
create: (_) => LocalizationBloc(),
|
|
),
|
|
],
|
|
child: ScreenUtilInit(
|
|
builder: (BuildContext context, Widget? child) =>
|
|
BlocBuilder<LocalizationBloc, LocalizationState>(
|
|
builder: (context, state) {
|
|
return MaterialApp.router(
|
|
title: 'Tanami Capital',
|
|
locale: state.locale,
|
|
supportedLocales: const [
|
|
Locale('en', ''),
|
|
Locale('ar', ''),
|
|
],
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
localeResolutionCallback: (locale, supportedLocales) {
|
|
for (var supportedLocale in supportedLocales) {
|
|
if (supportedLocale.languageCode == locale?.languageCode) {
|
|
return supportedLocale;
|
|
}
|
|
}
|
|
return supportedLocales.first;
|
|
},
|
|
theme: ThemeData(
|
|
useMaterial3: true,
|
|
),
|
|
debugShowCheckedModeBanner: false,
|
|
routerConfig: goRouter,
|
|
);
|
|
}),
|
|
designSize: const Size(390, 844),
|
|
),
|
|
);
|
|
}
|
|
}
|