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:
vjrj 2026-03-05 02:10:14 +01:00
parent 292cf65bbc
commit eb0d19621c
46 changed files with 586 additions and 697 deletions

View file

@ -4,10 +4,9 @@ import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:latlong/latlong.dart';
import 'package:share/share.dart';
import 'package:latlong2/latlong.dart';
import 'package:share_plus/share_plus.dart';
import 'attributionMapPlugin.dart';
import 'colors.dart';
@ -44,19 +43,19 @@ class _ViewModel {
final OnFirePressedInMap onFirePressed;
_ViewModel(
{@required this.mapState,
@required this.serverUrl,
@required this.lang,
@required this.onSubs,
@required this.onSubsConfirmed,
@required this.onUnSubs,
@required this.onSlide,
@required this.onEdit,
@required this.onEditing,
@required this.onEditConfirm,
@required this.onFalsePositive,
@required this.onFirePressed,
@required this.onEditCancel});
{required this.mapState,
required this.serverUrl,
required this.lang,
required this.onSubs,
required this.onSubsConfirmed,
required this.onUnSubs,
required this.onSlide,
required this.onEdit,
required this.onEditing,
required this.onEditConfirm,
required this.onFalsePositive,
required this.onFirePressed,
required this.onEditCancel});
@override
bool operator ==(Object other) =>
@ -81,15 +80,15 @@ class _genericMapState extends State<genericMap> {
// https://github.com/flutter/flutter/issues/1632#issuecomment-180478202
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
YourLocation _location;
YourLocation _initialLocation;
YourLocation? _location;
YourLocation? _initialLocation;
@override
Widget build(BuildContext context) {
return new StoreConnector<AppState, _ViewModel>(
distinct: true,
onInitialBuild: (store) {
_initialLocation = _location.copyWith();
_initialLocation = _location?.copyWith();
},
converter: (store) {
print('New map viewer');
@ -132,9 +131,8 @@ class _genericMapState extends State<genericMap> {
builder: (context, view) {
YourLocation location = view.mapState.yourLocation;
_location = location.copyWith();
print('New map builder with ${_location.description}');
print('New map builder with ${_location?.description}');
assert(_location != null);
FireMapState mapState = view.mapState;
FireMapStatus status = mapState.status;
FireMapLayer layer = mapState.layer;
@ -143,27 +141,13 @@ class _genericMapState extends State<genericMap> {
double maxZoom = 18.0; // works?
MapOptions mapOptions = new MapOptions(
center: new LatLng(_location.lat, _location.lon),
plugins: globals.isDevelopment
? [
new ZoomMapPlugin(),
new AttributionPlugin(),
new LayerSelectorMapPlugin()
]
: [
new DummyMapPlugin(),
new AttributionPlugin(),
new LayerSelectorMapPlugin()
],
// this works ?
interactive: true,
zoom: 13.0,
// THIS does not works as expected
initialCenter: new LatLng(_location!.lat, _location!.lon),
initialZoom: 13.0,
maxZoom: maxZoom,
onTap: (callback) {
onTap: (tapPosition, latLng) {
if (status == FireMapStatus.edit) {
_location = _location.copyWith(
lat: callback.latitude, lon: callback.longitude);
_location = _location!
.copyWith(lat: latLng.latitude, lon: latLng.longitude);
view.onEditing(_location);
}
},
@ -225,9 +209,8 @@ class _genericMapState extends State<genericMap> {
}
FlutterMap map = new FlutterMap(
options: mapOptions,
mapController: mapController,
layers: [
new TileLayerOptions(
children: [
new TileLayer(
maxZoom: maxZoom,
urlTemplate: baseLayer,
subdomains: subdomains,
@ -236,9 +219,9 @@ class _genericMapState extends State<genericMap> {
},
),
globals.isDevelopment
? new ZoomMapPluginOptions()
: new DummyMapPluginOptions(),
new MarkerLayerOptions(
? new ZoomMapPluginWidget()
: new DummyMapPluginWidget(),
new MarkerLayer(
markers: buildMarkers(
mapState.status == FireMapStatus.viewFireNotification
? new LatLng(mapState.fireNotification.lat,
@ -250,9 +233,9 @@ class _genericMapState extends State<genericMap> {
mapState.status == FireMapStatus.viewFireNotification,
view.onFirePressed),
),
// new AttributionPluginOptions(text: "© OpenStreetMap contributors"),
new LayerSelectorMapPluginOptions(),
new AttributionPluginOptions(text: attribution),
// new AttributionPluginWidget(text: "© OpenStreetMap contributors"),
new LayerSelectorMapPluginWidget(),
new AttributionPluginWidget(text: attribution),
],
);
// mapController.
@ -264,7 +247,7 @@ class _genericMapState extends State<genericMap> {
// Do something with it
return new Scaffold(
key: _scaffoldKey,
resizeToAvoidBottomPadding: true,
resizeToAvoidBottomInset: true,
appBar: new AppBar(
title: status == FireMapStatus.edit
? new TextField(
@ -416,9 +399,9 @@ class _genericMapState extends State<genericMap> {
var loc = LatLng(coords[1].toDouble(), coords[0].toDouble());
markers.add(FireMarker(loc, FireMarkType.falsePos));
if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
} catch (e) {
} catch (e, stackTrace) {
print('Failed to process $falsePos');
reportError(e, e.stackTrace);
reportError(e, stackTrace);
}
});
industries.forEach((industry) {
@ -428,9 +411,9 @@ class _genericMapState extends State<genericMap> {
var loc = LatLng(coords[1], coords[0]);
markers.add(FireMarker(loc, FireMarkType.industry));
if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel));
} catch (e) {
} catch (e, stackTrace) {
print('Failed to process $industry');
reportError(e, e.stackTrace);
reportError(e, stackTrace);
}
});
fires.forEach((fire) {
@ -441,9 +424,9 @@ class _genericMapState extends State<genericMap> {
print('fire $fire pressed');
}));
markers.add(FireMarker(loc, FireMarkType.pixel));
} catch (e) {
} catch (e, stackTrace) {
print('Failed to process $fire');
reportError(e, e.stackTrace);
reportError(e, stackTrace);
}
});
markers.add(
@ -462,11 +445,11 @@ class _genericMapState extends State<genericMap> {
String fireDesc =
S.of(context).additionalInfoAboutFire(reverseLoc, when, by);
showDialog<bool>(
context: _scaffoldKey.currentContext,
context: _scaffoldKey.currentContext!,
builder: (_) => new AlertDialog(
content: new Text(fireDesc),
actions: <Widget>[
new FlatButton(
new TextButton(
child: Text(S.of(context).CLOSE),
onPressed: () {
Navigator.pop(context);