import 'package:provider/provider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'flutter_flow/flutter_flow_theme.dart'; import 'flutter_flow/flutter_flow_util.dart'; import 'flutter_flow/internationalization.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); GoRouter.optionURLReflectsImperativeAPIs = true; usePathUrlStrategy(); await FlutterFlowTheme.initialize(); await FFLocalizations.initialize(); final appState = FFAppState(); // Initialize FFAppState await appState.initializePersistedState(); runApp(ChangeNotifierProvider( create: (context) => appState, child: const MyApp(), )); } class MyApp extends StatefulWidget { const MyApp({super.key}); // This widget is the root of your application. @override State createState() => _MyAppState(); static _MyAppState of(BuildContext context) => context.findAncestorStateOfType<_MyAppState>()!; } class _MyAppState extends State { Locale? _locale = FFLocalizations.getStoredLocale(); ThemeMode _themeMode = FlutterFlowTheme.themeMode; late AppStateNotifier _appStateNotifier; late GoRouter _router; bool displaySplashImage = true; @override void initState() { super.initState(); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); Future.delayed(const Duration(milliseconds: 1000), () => setState(() => _appStateNotifier.stopShowingSplashImage())); } void setLocale(String language) { setState(() => _locale = createLocale(language)); FFLocalizations.storeLocale(language); } void setThemeMode(ThemeMode mode) => setState(() { _themeMode = mode; FlutterFlowTheme.saveThemeMode(mode); }); @override Widget build(BuildContext context) { return MaterialApp.router( title: 'FREHub', localizationsDelegates: const [ FFLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], locale: _locale, supportedLocales: const [ Locale('pt'), Locale('en'), ], theme: ThemeData( brightness: Brightness.light, scrollbarTheme: ScrollbarThemeData( thumbVisibility: WidgetStateProperty.all(false), interactive: false, thumbColor: WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.dragged)) { return const Color(0xff1aab5f); } if (states.contains(WidgetState.hovered)) { return const Color(0xff1aab5f); } return const Color(0xff1aab5f); }), ), ), darkTheme: ThemeData( brightness: Brightness.dark, scrollbarTheme: ScrollbarThemeData( thumbVisibility: WidgetStateProperty.all(false), interactive: false, thumbColor: WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.dragged)) { return const Color(0xff1aab5f); } if (states.contains(WidgetState.hovered)) { return const Color(0xff1aab5f); } return const Color(0xff1aab5f); }), ), ), themeMode: _themeMode, routerConfig: _router, ); } }