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,12 +1,10 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:fires_flutter/models/fireNotification.dart';
|
||||
import 'package:fires_flutter/objectIdUtils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
|
@ -49,33 +47,11 @@ class HomePage extends StatefulWidget {
|
|||
class _HomePageState extends State<HomePage> {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
final Store<AppState> store = GetIt.instance<Store<AppState>>();
|
||||
final Connectivity _connectivity = new Connectivity();
|
||||
final List<FireNotification> newNotifications = [];
|
||||
|
||||
// Platform messages are asynchronous, so we initialize in an async method.
|
||||
Future<Null> initConnectivity() async {
|
||||
ConnectivityResult connectionStatus;
|
||||
// Platform messages may fail, so we use a try/catch PlatformException.
|
||||
try {
|
||||
connectionStatus = (await _connectivity.checkConnectivity());
|
||||
} on PlatformException catch (e) {
|
||||
print(e.toString());
|
||||
connectionStatus = ConnectivityResult.none;
|
||||
}
|
||||
|
||||
// If the widget was removed from the tree while the asynchronous platform
|
||||
// message was in flight, we want to discard the reply rather than calling
|
||||
// setState to update our non-existent appearance.
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
store.dispatch(new OnConnectivityChanged(connectionStatus));
|
||||
if (connectionStatus == ConnectivityResult.none) {
|
||||
_showDialog(S.of(context).noConnectivity);
|
||||
}
|
||||
});
|
||||
// Connectivity checking removed - no longer needed
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -84,17 +60,7 @@ class _HomePageState extends State<HomePage> {
|
|||
// Firebase Messaging v5+ setup
|
||||
_setupFirebaseMessaging();
|
||||
_getFirebaseToken();
|
||||
initConnectivity();
|
||||
// StreamSubscription<ConnectivityResult> _connectivitySubscription =
|
||||
_connectivity.onConnectivityChanged.listen((ConnectivityResult result) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
store.dispatch(new OnConnectivityChanged(result));
|
||||
// _showDialog(result.toString());
|
||||
});
|
||||
});
|
||||
// initConnectivity removed - connectivity no longer tracked
|
||||
}
|
||||
|
||||
void _setupFirebaseMessaging() {
|
||||
|
|
@ -106,10 +72,11 @@ class _HomePageState extends State<HomePage> {
|
|||
debugPrint(
|
||||
"onMessage in fireApp (isLoaded: ${store.state.isLoaded}): $message");
|
||||
if (message.data.isNotEmpty) {
|
||||
_showItemDialog(
|
||||
message.data as Map<String, dynamic>,
|
||||
_notifForMessage(
|
||||
message.data as Map<String, dynamic>, store.state.isLoaded));
|
||||
final notif = _notifForMessage(
|
||||
message.data, store.state.isLoaded);
|
||||
if (notif != null) {
|
||||
_showItemDialog(message.data, notif);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -119,8 +86,8 @@ class _HomePageState extends State<HomePage> {
|
|||
"onMessageOpenedApp (isLoaded: ${store.state.isLoaded}): $message");
|
||||
if (message.data.isNotEmpty) {
|
||||
_notifForMessage(
|
||||
message.data as Map<String, dynamic>, store.state.isLoaded);
|
||||
_navigateToItemDetail(message.data as Map<String, dynamic>);
|
||||
message.data, store.state.isLoaded);
|
||||
_navigateToItemDetail(message.data);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -129,7 +96,7 @@ class _HomePageState extends State<HomePage> {
|
|||
if (message != null) {
|
||||
debugPrint("App opened by notification: $message");
|
||||
if (message.data.isNotEmpty) {
|
||||
_navigateToItemDetail(message.data as Map<String, dynamic>);
|
||||
_navigateToItemDetail(message.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -212,7 +179,7 @@ class _HomePageState extends State<HomePage> {
|
|||
children: <Widget>[
|
||||
new IconButton(
|
||||
onPressed: () {
|
||||
_scaffoldKey.currentState.openDrawer();
|
||||
_scaffoldKey.currentState?.openDrawer();
|
||||
},
|
||||
icon: new Icon(Icons.menu,
|
||||
size: 30.0, color: Colors.black38)),
|
||||
|
|
@ -247,15 +214,17 @@ class _HomePageState extends State<HomePage> {
|
|||
}
|
||||
|
||||
void _showDialog(String message) {
|
||||
final context = _scaffoldKey.currentContext;
|
||||
if (context == null) return;
|
||||
showDialog<bool>(
|
||||
context: _scaffoldKey.currentContext,
|
||||
context: context,
|
||||
builder: (_) => new AlertDialog(
|
||||
content: new Text(message),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: Text(S.of(_scaffoldKey.currentContext).CLOSE),
|
||||
new TextButton(
|
||||
child: Text(S.of(context).CLOSE),
|
||||
onPressed: () {
|
||||
Navigator.pop(_scaffoldKey.currentContext);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
@ -263,10 +232,12 @@ class _HomePageState extends State<HomePage> {
|
|||
}
|
||||
|
||||
void _showItemDialog(Map<String, dynamic> message, FireNotification notif) {
|
||||
final context = _scaffoldKey.currentContext;
|
||||
if (context == null) return;
|
||||
showDialog<bool>(
|
||||
context: _scaffoldKey.currentContext,
|
||||
builder: (_) => _buildDialog(_scaffoldKey.currentContext, notif),
|
||||
).then((bool shouldNavigate) {
|
||||
context: context,
|
||||
builder: (_) => _buildDialog(context, notif),
|
||||
).then((bool? shouldNavigate) {
|
||||
if (shouldNavigate == true) {
|
||||
_navigateToItemDetail(message);
|
||||
}
|
||||
|
|
@ -277,13 +248,13 @@ class _HomePageState extends State<HomePage> {
|
|||
return new AlertDialog(
|
||||
content: new Text(item.description),
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
new TextButton(
|
||||
child: Text(S.of(context).CLOSE),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
new FlatButton(
|
||||
new TextButton(
|
||||
child: Text(S.of(context).SHOW),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
|
@ -294,14 +265,14 @@ class _HomePageState extends State<HomePage> {
|
|||
}
|
||||
|
||||
void _navigateToItemDetail(Map<String, dynamic> message) {
|
||||
final context = _scaffoldKey.currentContext;
|
||||
if (context == null) return;
|
||||
// Clear away dialogs
|
||||
Navigator.popUntil(_scaffoldKey.currentContext,
|
||||
(Route<dynamic> route) => route is PageRoute);
|
||||
Navigator.popUntil(context, (Route<dynamic> route) => route is PageRoute);
|
||||
/* if (!notif.getRoute(store).isCurrent) {
|
||||
// Navigator.push(_scaffoldKey.currentContext, notif.getRoute(store));
|
||||
// Navigator.push(context, notif.getRoute(store));
|
||||
} */
|
||||
Navigator.pushNamed(
|
||||
_scaffoldKey.currentContext, FireNotificationList.routeName);
|
||||
Navigator.pushNamed(context, FireNotificationList.routeName);
|
||||
}
|
||||
|
||||
// Firebase Messaging instance (v5+)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue