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,8 +1,6 @@
import 'dart:async';
import 'package:comunes_flutter/comunes_flutter.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter/material.dart';
import 'colors.dart';
@ -12,90 +10,87 @@ import 'generated/i18n.dart';
import 'models/appState.dart';
import 'models/falsePositiveTypes.dart';
import 'models/fireMapState.dart';
import 'models/fireNotification.dart';
import 'models/yourLocation.dart';
typedef void OnSave();
typedef void OnCancel();
typedef void OnFalsePositive(FireNotification notif, FalsePositiveType type);
typedef OnSave = void Function();
typedef OnCancel = void Function();
typedef OnFalsePositive = void Function(FireNotification notif, FalsePositiveType type);
class GenericMapBottom extends StatelessWidget {
const GenericMapBottom(
{super.key, required this.onSave,
required this.onCancel,
required this.onFalsePositive,
required this.state,
required this.scaffoldKey});
final OnSave onSave;
final OnCancel onCancel;
final OnFalsePositive onFalsePositive;
final FireMapState state;
final GlobalKey<ScaffoldState> scaffoldKey;
GenericMapBottom(
{required this.onSave,
required this.onCancel,
required this.onFalsePositive,
required this.state,
required this.scaffoldKey});
@override
Widget build(BuildContext context) {
final YourLocation? locOrNull = state.yourLocation;
if (locOrNull == null) {
return SizedBox.shrink();
return const SizedBox.shrink();
}
final YourLocation loc = locOrNull;
int kmAround = loc.distance;
return new CustomBottomAppBar(
final int kmAround = loc.distance;
return CustomBottomAppBar(
fabLocation: FloatingActionButtonLocation.centerFloat,
showNotch: false,
color: fires100,
mainAxisAlignment: MainAxisAlignment.center,
actions: buildActionList(loc, context, kmAround, scaffoldKey));
}
List<Widget> buildActionList(YourLocation loc, BuildContext context,
int kmAround, GlobalKey<ScaffoldState> scaffoldState) {
List<Widget> actionList = [];
final List<Widget> actionList = <Widget>[];
switch (state.status) {
case FireMapStatus.edit:
actionList.add(TextButton(
onPressed: onSave,
child: new Text(S.of(context).SAVE,
child: Text(S.of(context).SAVE,
style: Theme.of(context).textTheme.labelLarge)));
actionList.add(TextButton(
onPressed: onCancel,
child: new Text(S.of(context).CANCEL,
child: Text(S.of(context).CANCEL,
style: Theme.of(context).textTheme.labelLarge)));
break;
case FireMapStatus.subscriptionConfirm:
break;
case FireMapStatus.viewFireNotification:
final notif = state.fireNotification;
final FireNotification? notif = state.fireNotification;
if (notif != null) {
actionList.add(new Flexible(
child: new Padding(
padding: new EdgeInsets.all(10.0),
child: new Column(
actionList.add(Flexible(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: listWithoutNulls(<Widget?>[
new Text(notif.description),
// TODO fire type (neighbout, NASA, etc)
new SizedBox(height: 5.0),
new Row(
Text(notif.description),
// TODOfire type (neighbout, NASA, etc)
const SizedBox(height: 5.0),
Row(
children: <Widget>[
new Icon(Icons.access_time),
new SizedBox(width: 5.0),
new Text(Moment.now().from(context, notif.when)),
const Icon(Icons.access_time),
const SizedBox(width: 5.0),
Text(Moment.now().from(context, notif.when)),
],
),
state.industries.length > 0 || state.falsePos.length > 0
? new Padding(
padding: new EdgeInsets.only(top: 10.0),
child: new Text(
if (state.industries.isNotEmpty || state.falsePos.isNotEmpty) Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Text(
S.of(context).itSeemsNotAtForesFire,
style: new TextStyle(color: fires600)))
: null,
new DropdownButton<FalsePositiveType>(
style: new TextStyle(
style: const TextStyle(color: fires600))) else null,
DropdownButton<FalsePositiveType>(
style: const TextStyle(
color: Colors.black,
// fontSize: 18.0,
),
hint: new Text(S.of(context).notAWildfire),
hint: Text(S.of(context).notAWildfire),
items: FalsePositiveType.values
.map((FalsePositiveType value) {
String menuText;
@ -110,18 +105,18 @@ class GenericMapBottom extends StatelessWidget {
case FalsePositiveType.falsealarm:
menuText = S.of(context).itSeemsAFalseAlarm;
}
return new DropdownMenuItem<FalsePositiveType>(
value: value, child: new Text(menuText));
return DropdownMenuItem<FalsePositiveType>(
value: value, child: Text(menuText));
}).toList(),
onChanged: (FalsePositiveType? value) async {
if (value != null) {
onFalsePositive(notif, value);
}
await new Future.delayed(
new Duration(milliseconds: 500));
await Future.delayed(
const Duration(milliseconds: 500));
ScaffoldMessenger.of(context)
.showSnackBar(new SnackBar(
content: new Text(
.showSnackBar(SnackBar(
content: Text(
S.of(context).thanksForParticipating),
));
}),
@ -130,7 +125,7 @@ class GenericMapBottom extends StatelessWidget {
break;
case FireMapStatus.unsubscribe:
case FireMapStatus.view:
actionList.add(new Text(state.numFires > 0
actionList.add(Text(state.numFires > 0
? loc.currentNumFires == 1
? S.of(context).fireAroundThisArea(loc.distance.toString())
: S.of(context).firesAroundThisArea(