Fix remaining compilation errors: null-safety, removed packages, and nullable handling
- Fix AppState: remove removed connectivity package, fix imports (latlong2), make nullable fields optional - Fix User model: use const empty strings in const constructor instead of null - Fix model builders: add required ObjectId parameters to YourLocation and FireNotification - Implement Comparable instead of extending it for BasicLocation - Fix nullable callback handling in appActions and middleware (Completer<Null>?) - Add null checks for BuildContext in dialogs (fireAlert, homePage, etc.) - Fix nullable scaffold state access using ?. operator (activeFires, fireNotificationList) - Handle nullable FireNotification and YourLocation in genericMapBottom - Fix list type casting for widgets that can be null (<Widget?> with filtering) - Add ObjectId imports where needed for model creation - Fix Key? nullable parameter in introPage - Add required parameters to markdownPage and slider constructors - Remove connectivity-related code and imports (package removed) - Handle nullable Completer in fetchDataMiddleware All 104 errors resolved. 0 errors, 61 warnings/info remaining.
This commit is contained in:
parent
037b5eaa32
commit
a7f3ab6974
27 changed files with 259 additions and 274 deletions
|
|
@ -1,13 +1,12 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:connectivity/connectivity.dart';
|
||||
import 'package:fires_flutter/models/fireNotification.dart';
|
||||
import 'package:fires_flutter/models/yourLocation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:latlong/latlong.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'fireMapState.dart';
|
||||
|
|
@ -44,8 +43,6 @@ class AppState {
|
|||
final int fireNotificationsUnread;
|
||||
@JsonKey(ignore: true)
|
||||
final FireMapState fireMapState;
|
||||
@JsonKey(ignore: true)
|
||||
final ConnectivityResult connectivity;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
factory AppState.fromJson(Map<String, dynamic> json) =>
|
||||
|
|
@ -57,31 +54,29 @@ class AppState {
|
|||
this.fireNotificationsUnread = 0,
|
||||
this.user = const User.initial(),
|
||||
this.isLoading = false,
|
||||
this.isLoaded= false,
|
||||
this.error,
|
||||
this.gmapKey,
|
||||
this.firesApiKey,
|
||||
this.firesApiUrl,
|
||||
this.serverUrl,
|
||||
this.connectivity,
|
||||
this.monitoredAreas,
|
||||
this.isLoaded = false,
|
||||
this.error = '',
|
||||
this.gmapKey = '',
|
||||
this.firesApiKey = '',
|
||||
this.firesApiUrl = '',
|
||||
this.serverUrl = '',
|
||||
this.monitoredAreas = const <Polyline>[],
|
||||
this.fireMapState = const FireMapState.initial()});
|
||||
|
||||
AppState copyWith(
|
||||
{bool isLoading,
|
||||
bool isLoaded,
|
||||
String user,
|
||||
String error,
|
||||
String gmapKey,
|
||||
String firesApiKey,
|
||||
String serverUrl,
|
||||
String firesApiUrl,
|
||||
List<YourLocation> yourLocations,
|
||||
List<FireNotification> fireNotifications,
|
||||
int fireNotificationsUnread,
|
||||
FireMapState fireMapState,
|
||||
List<Polyline> monitoredAreas,
|
||||
ConnectivityResult connectivity}) {
|
||||
{bool? isLoading,
|
||||
bool? isLoaded,
|
||||
User? user,
|
||||
String? error,
|
||||
String? gmapKey,
|
||||
String? firesApiKey,
|
||||
String? serverUrl,
|
||||
String? firesApiUrl,
|
||||
List<YourLocation>? yourLocations,
|
||||
List<FireNotification>? fireNotifications,
|
||||
int? fireNotificationsUnread,
|
||||
FireMapState? fireMapState,
|
||||
List<Polyline>? monitoredAreas}) {
|
||||
return new AppState(
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
isLoaded: isLoaded ?? this.isLoaded,
|
||||
|
|
@ -96,13 +91,12 @@ class AppState {
|
|||
fireNotificationsUnread:
|
||||
fireNotificationsUnread ?? this.fireNotificationsUnread,
|
||||
monitoredAreas: monitoredAreas ?? this.monitoredAreas,
|
||||
fireMapState: fireMapState ?? this.fireMapState,
|
||||
connectivity: connectivity ?? this.connectivity);
|
||||
fireMapState: fireMapState ?? this.fireMapState);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppState{\nuser: $user\nconnectivity: ${connectivity.toString()}\nisLoading: $isLoading\nisLoaded: $isLoaded\napiKey: ${ellipse(firesApiKey, 8)}\napiUrl: $firesApiUrl\nserverUrl: $serverUrl\nfireMapState: $fireMapState\nyourLocations count: ${yourLocations.length}\nunread notif: $fireNotificationsUnread\nfireNotifications: $fireNotifications\nyourLocations: $yourLocations}';
|
||||
return 'AppState{\nuser: $user\nisLoading: $isLoading\nisLoaded: $isLoaded\napiKey: ${ellipse(firesApiKey, 8)}\napiUrl: $firesApiUrl\nserverUrl: $serverUrl\nfireMapState: $fireMapState\nyourLocations count: ${yourLocations.length}\nunread notif: $fireNotificationsUnread\nfireNotifications: $fireNotifications\nyourLocations: $yourLocations}';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,11 @@
|
|||
|
||||
class BasicLocation extends Comparable<BasicLocation> {
|
||||
class BasicLocation implements Comparable<BasicLocation> {
|
||||
final double lat;
|
||||
final double lon;
|
||||
String description;
|
||||
final String? description;
|
||||
|
||||
// static BasicLocation noLocation = new BasicLocation(lat: 0.0, lon: 0.0);
|
||||
|
||||
BasicLocation({required this.lat, required this.lon, this.description}) {
|
||||
|
||||
}
|
||||
BasicLocation({required this.lat, required this.lon, this.description}) {}
|
||||
|
||||
int compareTo(BasicLocation other) {
|
||||
return lat == other.lat && lon == other.lon ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -24,16 +24,14 @@ class FireNotification {
|
|||
_$FireNotificationFromJson(json);
|
||||
|
||||
FireNotification(
|
||||
{this.id,
|
||||
{required this.id,
|
||||
required this.lat,
|
||||
required this.lon,
|
||||
required this.description,
|
||||
required this.when,
|
||||
required this.read,
|
||||
required this.sealed,
|
||||
required this.subsId}) {
|
||||
|
||||
}
|
||||
required this.subsId}) {}
|
||||
|
||||
FireNotification copyWith(
|
||||
{id, lat, lon, description, read, when, sealed, subsId}) {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ final String fireNotificationKey = 'fireNotifications';
|
|||
|
||||
Future<List<FireNotification>> loadFireNotifications() async {
|
||||
return await globals.prefs.then((prefs) {
|
||||
List<String> FireNotifications = prefs.getStringList(fireNotificationKey);
|
||||
List<String>? FireNotifications = prefs.getStringList(fireNotificationKey);
|
||||
List<FireNotification> persistedList = [];
|
||||
FireNotifications.forEach((notificationString) {
|
||||
(FireNotifications ?? []).forEach((notificationString) {
|
||||
Map notificationMap = json.decode(notificationString);
|
||||
persistedList.add(FireNotification.fromJson(notificationMap));
|
||||
persistedList.add(
|
||||
FireNotification.fromJson(notificationMap as Map<String, dynamic>));
|
||||
});
|
||||
return persistedList;
|
||||
return persistedList;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ class User {
|
|||
final String token;
|
||||
|
||||
const User.initial()
|
||||
: this.userId = null,
|
||||
lang = null,
|
||||
token = null;
|
||||
: userId = '',
|
||||
lang = '',
|
||||
token = '';
|
||||
|
||||
User({this.userId, this.lang, this.token});
|
||||
const User({required this.userId, required this.lang, required this.token});
|
||||
|
||||
User copyWith({String userId, String lang, String token}) {
|
||||
User copyWith({String? userId, String? lang, String? token}) {
|
||||
return new User(
|
||||
userId: userId ?? this.userId,
|
||||
token: token ?? this.token,
|
||||
|
|
@ -25,5 +25,4 @@ class User {
|
|||
String toString() {
|
||||
return 'User {userId: $userId, lang: $lang, token: ${ellipse(token)}';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,28 @@ class YourLocation {
|
|||
String description;
|
||||
bool subscribed;
|
||||
int distance;
|
||||
int currentNumFires;
|
||||
late int currentNumFires;
|
||||
|
||||
factory YourLocation.fromJson(Map<String, dynamic> json) =>
|
||||
_$YourLocationFromJson(json);
|
||||
|
||||
static YourLocation noLocation = new YourLocation(lat: 0.0, lon: 0.0);
|
||||
static const int withoutStats = null;
|
||||
static late final YourLocation noLocation;
|
||||
static const int? withoutStats = null;
|
||||
|
||||
static void _initNoLocation() {
|
||||
noLocation = new YourLocation(
|
||||
id: ObjectId(), lat: 0.0, lon: 0.0, description: '', subscribed: false);
|
||||
}
|
||||
|
||||
YourLocation(
|
||||
{this.id,
|
||||
{required this.id,
|
||||
required this.lat,
|
||||
required this.lon,
|
||||
this.description,
|
||||
this.description = '',
|
||||
this.distance = 10,
|
||||
int currentNumFires = withoutStats,
|
||||
this.subscribed =false}) {
|
||||
|
||||
int? currentNumFires,
|
||||
this.subscribed = false}) {
|
||||
this.currentNumFires = currentNumFires ?? 0;
|
||||
}
|
||||
Map<String, dynamic> toJson() => _$YourLocationToJson(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ final String locationKey = 'yourlocations';
|
|||
|
||||
Future<List<YourLocation>> loadYourLocations() async {
|
||||
return await globals.prefs.then((prefs) {
|
||||
List<String> yourLocations = prefs.getStringList(locationKey);
|
||||
List<String>? yourLocations = prefs.getStringList(locationKey);
|
||||
List<YourLocation> persistedList = [];
|
||||
yourLocations.forEach((locationString) {
|
||||
(yourLocations ?? []).forEach((locationString) {
|
||||
Map locationMap = json.decode(locationString);
|
||||
persistedList.add(YourLocation.fromJson(locationMap));
|
||||
persistedList
|
||||
.add(YourLocation.fromJson(locationMap as Map<String, dynamic>));
|
||||
});
|
||||
return persistedList;
|
||||
return persistedList;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue