Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

3 years ago
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_zxing_example/utils/extensions.dart';
import 'package:nb_utils/nb_utils.dart';
3 years ago
import 'configs/app_store.dart';
import 'configs/app_theme.dart';
import 'generated/l10n.dart' as loc;
import 'utils/router.dart';
import 'utils/scroll_behavior.dart';
3 years ago
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await _initializeAppStore();
3 years ago
runApp(const MyApp());
}
_initializeAppStore() async {
await initialize();
final themeModeString = getStringAsync(
themeModePref,
defaultValue: appStore.themeMode.toString(),
);
await appStore.setThemeMode(
ThemeMode.values
.firstWhere((element) => element.toString() == themeModeString),
);
await appStore.setColorSchemeIndex(
getIntAsync(colorSchemeIndexPref, defaultValue: appStore.colorSchemeIndex),
);
await appStore.toggleSoundMode(
value: getBoolAsync(isSoundOnPref, defaultValue: appStore.isSoundOn),
);
await appStore.toggleVibrationMode(
value:
getBoolAsync(isVibrationOnPref, defaultValue: appStore.isVibrationOn),
);
await appStore.setLanguage(
getStringAsync(languagePref, defaultValue: appStore.selectedLanguage),
);
}
3 years ago
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _appRouter = AppRouter();
3 years ago
@override
Widget build(BuildContext context) {
return Observer(
builder: (_) => MaterialApp(
title: 'ZxScanner',
theme: AppTheme.flexLightTheme(),
darkTheme: AppTheme.flexDarkTheme(),
themeMode: appStore.themeMode,
localizationsDelegates: const [
loc.S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: loc.S.delegate.supportedLocales,
locale: appStore.selectedLanguage.parseLocale(),
onGenerateRoute: _appRouter.onGenerateRoute,
scrollBehavior: MyCustomScrollBehavior(),
debugShowCheckedModeBanner: false,
),
3 years ago
);
}
}