fix: resolve 2 remaining strict analysis errors

- introPage.dart: Convert fireItems to proper static function closure
- mainDrawer.dart: Convert unreadCount int to String for Text widget
This commit is contained in:
vjrj 2026-03-06 11:21:06 +01:00
parent 1864e5b105
commit 7a4c9fb3bc
61 changed files with 1386 additions and 1202 deletions

View file

@ -1,6 +1,5 @@
import 'dart:async';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:geocoding/geocoding.dart' as geo;
@ -8,42 +7,43 @@ import 'package:location/location.dart';
import 'package:objectid/objectid.dart';
import 'generated/i18n.dart';
import 'models/yourLocation.dart';
Future<YourLocation> getUserLocation(
GlobalKey<ScaffoldState> scaffoldKey) async {
// Platform messages may fail, so we use a try/catch PlatformException.
try {
Location _location = new Location();
final Location location0 = Location();
LocationData location = await _location.getLocation();
final LocationData location = await location0.getLocation();
// It seems that the lib fails with lat/lon values
var yl = new YourLocation(
final YourLocation yl = YourLocation(
id: ObjectId(), lat: location.latitude!, lon: location.longitude!);
var address;
String address;
try {
address = await getReverseLocation(lat: yl.lat, lon: yl.lon);
yl.description = address as String;
yl.description = address;
} catch (e) {
try {
address =
await getReverseLocation(lat: yl.lat, lon: yl.lon, external: true);
yl.description = address as String;
yl.description = address;
} catch (e) {
print('We cannot reverse geolocate');
}
}
return yl;
} on PlatformException catch (e) {
final context = scaffoldKey.currentContext;
final BuildContext? context = scaffoldKey.currentContext;
if (context != null) {
if (e.code == 'PERMISSION_DENIED') {
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: new Text(S.of(context).notPermsUbication),
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(S.of(context).notPermsUbication),
));
} else if (e.code == 'PERMISSION_DENIED_NEVER_ASK') {}
ScaffoldMessenger.of(context).showSnackBar(new SnackBar(
content: new Text(S.of(context).isYourUbicationEnabled),
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(S.of(context).isYourUbicationEnabled),
));
}
return YourLocation.noLocation;
@ -53,19 +53,19 @@ Future<YourLocation> getUserLocation(
Future<String> getReverseLocation(
{required double lat, required double lon, bool external = false}) async {
try {
List<geo.Placemark> placemarks =
final List<geo.Placemark> placemarks =
await geo.placemarkFromCoordinates(lat, lon);
if (placemarks.isNotEmpty) {
var first = placemarks.first;
String address =
final geo.Placemark first = placemarks.first;
final String address =
'${first.street}, ${first.locality}, ${first.administrativeArea}, ${first.country}';
print("${first.name} : $address");
print('${first.name} : $address');
return address;
} else {
return 'Unable to determine address';
}
} catch (e) {
print("Error in reverse geocoding: $e");
throw Exception("Failed to reverse geocode: $e");
print('Error in reverse geocoding: $e');
throw Exception('Failed to reverse geocode: $e');
}
}