Migrate fires_flutter to flutter_map v6.1.0 and complete major null-safety fixes
- 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
This commit is contained in:
parent
292cf65bbc
commit
eb0d19621c
46 changed files with 586 additions and 697 deletions
|
|
@ -2,8 +2,7 @@ import 'dart:async';
|
|||
|
||||
import 'package:fires_flutter/models/fireNotification.dart';
|
||||
import 'package:fires_flutter/models/yourLocation.dart';
|
||||
import 'package:flutter_simple_dependency_injection/injector.dart';
|
||||
import 'package:just_debounce_it/just_debounce_it.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:objectid/objectid.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
|
|
@ -23,21 +22,27 @@ import 'actions.dart';
|
|||
// Middleware do not return any values themselves. They simply forward
|
||||
// actions on to the Reducer or swallow actions in some special cases.
|
||||
|
||||
FiresApi api = Injector.getInjector().get<FiresApi>();
|
||||
FiresApi api = GetIt.instance<FiresApi>();
|
||||
|
||||
// Simple debounce mechanism
|
||||
Timer? _locationUpdateDebounceTimer;
|
||||
|
||||
void debounceLocationUpdate(Duration duration, Function() callback) {
|
||||
_locationUpdateDebounceTimer?.cancel();
|
||||
_locationUpdateDebounceTimer = Timer(duration, callback);
|
||||
}
|
||||
|
||||
void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
||||
// If our Middleware encounters a `FetchYourLocationAction`
|
||||
|
||||
if (action is OnUserLangAction) {
|
||||
// I can create the user with the lang and the token
|
||||
if (store.state.user.token != null)
|
||||
createUser(store, action.lang, store.state.user.token);
|
||||
createUser(store, action.lang, store.state.user.token);
|
||||
}
|
||||
|
||||
if (action is OnUserTokenAction) {
|
||||
// I can create the user with the lang and the token
|
||||
if (store.state.user.lang != null)
|
||||
createUser(store, store.state.user.lang, action.token);
|
||||
createUser(store, store.state.user.lang, action.token);
|
||||
}
|
||||
|
||||
if (action is EditConfirmYourLocationAction) {
|
||||
|
|
@ -98,8 +103,8 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
|
||||
if (action is UpdateYourLocationAction) {
|
||||
if (action.loc.subscribed)
|
||||
Debounce.seconds(
|
||||
2,
|
||||
debounceLocationUpdate(
|
||||
Duration(seconds: 2),
|
||||
() => api
|
||||
.getFiresInLocation(
|
||||
state: store.state,
|
||||
|
|
@ -149,20 +154,18 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
// If it succeeds, dispatch a success action with the YourLocations.
|
||||
// Our reducer will then update the State using these YourLocations.
|
||||
print('Subscribed to: ${subscribedLocations.length}');
|
||||
if (subscribedLocations is List) {
|
||||
// unsubscribe all locally to sync the subs state
|
||||
localLocations.forEach((location) => location.subscribed = false);
|
||||
print('Local persisted: ${localLocations.length}');
|
||||
subscribedLocations.forEach((subsLoc) {
|
||||
var locSubs = localLocations.firstWhere(
|
||||
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
|
||||
localLocations.add(subsLoc);
|
||||
return subsLoc;
|
||||
});
|
||||
locSubs.subscribed = true;
|
||||
// unsubscribe all locally to sync the subs state
|
||||
localLocations.forEach((location) => location.subscribed = false);
|
||||
print('Local persisted: ${localLocations.length}');
|
||||
subscribedLocations.forEach((subsLoc) {
|
||||
var locSubs = localLocations.firstWhere(
|
||||
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
|
||||
localLocations.add(subsLoc);
|
||||
return subsLoc;
|
||||
});
|
||||
}
|
||||
|
||||
locSubs.subscribed = true;
|
||||
});
|
||||
|
||||
store.dispatch(new FetchYourLocationsSucceededAction(localLocations));
|
||||
persistYourLocations(localLocations);
|
||||
|
||||
|
|
@ -180,10 +183,8 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
|
|||
});
|
||||
|
||||
Completer<Null> completer = action.refreshCallback;
|
||||
if (completer != null) {
|
||||
completer.complete(null);
|
||||
}
|
||||
});
|
||||
completer.complete(null);
|
||||
});
|
||||
}).catchError((onError) {
|
||||
// If it fails, dispatch a failure action. The reducer will
|
||||
// update the state with the error.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue