- Updated Android build files: gradle plugin 8.2.2, gradle 8.3, SDK 34, minSdk 21 - Ran dart fix --apply for 87 automatic null-safety fixes - Migrated flutter_map v6 API breaking changes: - MapOptions: center → initialCenter, zoom → initialZoom - layers → children structure - TileLayerOptions/MarkerLayerOptions/PolylineLayerOptions → TileLayer/MarkerLayer/PolylineLayer - Removed plugin_api.dart imports - Converted old plugin system (ZoomMapPlugin, AttributionPlugin, etc.) to direct widgets - Updated onTap callback signature: (TapPosition) → (TapPosition, LatLng) - Migrated all marker/polyline creation to v6 API - Fixed FlatButton → TextButton deprecation - Fixed stackTrace access with catch(e, stackTrace) pattern - Removed deprecated flutter_google_places_autocomplete dependency - Removed deprecated dependencies: latlong, connectivity, launch_review - Updated all imports from latlong → latlong2 - Placeholder implementation for places autocomplete (feature temporarily disabled) Remaining tasks (non-blocking for build): - Complete null-safety fixes for _location variables in genericMap.dart - Fix theme.dart MaterialTheme parameter issues - Fix customStepper.dart null-safety issues - Final build and testing
82 lines
3 KiB
Dart
82 lines
3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:comunes_flutter/comunes_flutter.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:redux/redux.dart';
|
|
|
|
import 'firesApp.dart';
|
|
import 'globals.dart' as globals;
|
|
import 'models/appState.dart';
|
|
import 'models/firesApi.dart';
|
|
import 'redux/fetchDataMiddleware.dart';
|
|
import 'redux/reducers.dart';
|
|
import 'sentryReport.dart';
|
|
|
|
Future<PackageInfo> loadPackageInfo() async {
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
return packageInfo;
|
|
}
|
|
|
|
Future<Map<String, dynamic>> loadSecrets() async {
|
|
return await SecretLoader(
|
|
secretPath: globals.isDevelopment
|
|
? 'assets/private-settings-dev.json'
|
|
: 'assets/private-settings.json')
|
|
.load();
|
|
}
|
|
|
|
void mainCommon(List<Middleware<AppState>> otherMiddleware) {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final getIt = GetIt.instance;
|
|
getIt.registerSingleton<FiresApi>(FiresApi());
|
|
loadPackageInfo().then((packageInfo) {
|
|
globals.appVersion = packageInfo.version;
|
|
print('Running version ${packageInfo.version}');
|
|
loadSecrets().then((secrets) {
|
|
final store = Store<AppState>(appStateReducer,
|
|
initialState: AppState(
|
|
gmapKey: secrets['gmapKey'],
|
|
firesApiKey: secrets['firesApiKey'],
|
|
serverUrl: secrets['firesApiUrl'],
|
|
firesApiUrl: secrets['firesApiUrl'] + "api/v1/"),
|
|
middleware: List.from(otherMiddleware)..add(fetchDataMiddleware));
|
|
|
|
getIt.registerSingleton<Store<AppState>>(store);
|
|
getIt.registerSingleton<String>(store.state.firesApiUrl,
|
|
instanceName: "firesApiUrl");
|
|
getIt.registerSingleton<String>(store.state.firesApiKey,
|
|
instanceName: "firesApiKey");
|
|
getIt.registerSingleton<String>(store.state.serverUrl,
|
|
instanceName: "serverUrl");
|
|
getIt.registerSingleton<String>(store.state.gmapKey,
|
|
instanceName: "gmapKey");
|
|
|
|
// https://flutter.io/cookbook/maintenance/error-reporting/
|
|
runZonedGuarded<Future<void>>(() async {
|
|
runApp(FiresApp(store));
|
|
}, (Object error, StackTrace? stackTrace) {
|
|
// Whenever an error occurs, call the `_reportError` function. This will send
|
|
// Dart errors to our dev console or Sentry depending on the environment.
|
|
reportError(error, stackTrace ?? StackTrace.current);
|
|
});
|
|
|
|
// Listen to store changes, and re-render when the state is updated
|
|
store.onChange.listen((state) {
|
|
// print('Store onChange');
|
|
});
|
|
FlutterError.onError = (FlutterErrorDetails details) {
|
|
if (!useSentry) {
|
|
// In development mode simply print to console.
|
|
FlutterError.dumpErrorToConsole(details);
|
|
} else {
|
|
// In production mode report to the application zone to report to
|
|
// Sentry.
|
|
Zone.current.handleUncaughtError(
|
|
details.exception, details.stack ?? StackTrace.current);
|
|
}
|
|
};
|
|
});
|
|
});
|
|
}
|