Remove the external comunes-flutter library dependency and replace all its components with local implementations: - Utility functions: Created lib/utils/widget_utils.dart with compactWidgets() and ellipse() functions, replacing the comunes-flutter helpers with modern Dart null-safety patterns (whereType instead of where(notNull)) - Secret loader: Inlined as lib/utils/secret_loader.dart for loading JSON config - Layout widgets: Replaced CenteredRow/CenteredColumn with standard Row/Column with MainAxisAlignment.center - Intro screens: Copied AppIntroPage and MaterialAppWithIntro locally in lib/widgets/ with cleaned-up deprecated code patterns - Button widget: Created lib/widgets/rounded_btn.dart for the RoundedBtn used in activeFires.dart Changes span 20 files: - 5 new utility/widget files created - Updated imports in 15 files - Removed path dependency from pubspec.yaml - All functionality preserved, build verified with flutter pub get Impact: - Removes external dependency, simplifying project structure - Modern Dart patterns (proper null-safety) - Better code clarity with explicit widget properties - Easier onboarding (no 'what is comunes-flutter?' questions)
83 lines
2.8 KiB
Dart
83 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_redux/flutter_redux.dart';
|
|
import 'package:redux/redux.dart';
|
|
|
|
import 'activeFires.dart';
|
|
import 'fireAlert.dart';
|
|
import 'fireNotificationList.dart';
|
|
import 'generated/i18n.dart';
|
|
import 'globals.dart';
|
|
import 'homePage.dart';
|
|
import 'introPage.dart';
|
|
import 'models/appState.dart';
|
|
import 'monitoredAreas.dart';
|
|
import 'privacyPage.dart';
|
|
import 'sandbox.dart';
|
|
import 'supportPage.dart';
|
|
import 'theme.dart';
|
|
import 'themeDev.dart';
|
|
import 'widgets/material_app_with_intro.dart';
|
|
|
|
class FiresApp extends StatefulWidget {
|
|
const FiresApp(this.store, {super.key});
|
|
|
|
final Store<AppState> store;
|
|
|
|
@override
|
|
_FiresAppState createState() => _FiresAppState();
|
|
}
|
|
|
|
class _FiresAppState extends State<FiresApp> {
|
|
// globals.getIt.registerSingleton
|
|
_FiresAppState();
|
|
late final Store<AppState> store;
|
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|
static Widget introWidget(BuildContext context) => IntroPage();
|
|
static Widget continueWidget(BuildContext context) => const HomePage();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
store = widget.store;
|
|
}
|
|
|
|
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
|
IntroPage.routeName: introWidget,
|
|
HomePage.routeName: continueWidget,
|
|
PrivacyPage.routeName: (BuildContext context) => PrivacyPage(context),
|
|
ActiveFiresPage.routeName: (BuildContext context) =>
|
|
const ActiveFiresPage(),
|
|
Sandbox.routeName: (BuildContext context) => const Sandbox(),
|
|
FireAlert.routeName: (BuildContext context) => const FireAlert(),
|
|
SupportPage.routeName: (BuildContext context) => const SupportPage(),
|
|
FireNotificationList.routeName: (BuildContext context) =>
|
|
const FireNotificationList(),
|
|
MonitoredAreasPage.routeName: (BuildContext context) =>
|
|
const MonitoredAreasPage()
|
|
};
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final StatefulWidget home = MaterialAppWithIntroHome(
|
|
introWidget, continueWidget, 'showInitialWizard-2018-06-27-01');
|
|
return StoreProvider<AppState>(
|
|
store: store,
|
|
child: MaterialApp(
|
|
navigatorKey: navigatorKey,
|
|
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
],
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
localeResolutionCallback:
|
|
S.delegate.resolution(fallback: const Locale('en', '')),
|
|
home: home,
|
|
onGenerateTitle: (BuildContext context) {
|
|
return S.of(context).appName;
|
|
},
|
|
theme: isDevelopment ? devFiresTheme : firesTheme,
|
|
routes: routes));
|
|
}
|
|
}
|