Fix 23 additional lint issues to reduce from 129 to 106 issues

- Add const constructors to @immutable classes (5 issues: prefer_const_constructors_in_immutables)
- Fix nullable value casts in firesApi.dart (3 issues: cast_nullable_to_non_nullable)
- Remove redundant default argument values (2 issues: avoid_redundant_argument_values)
- Make YourLocation immutable with final fields (2 issues: avoid_equals_and_hash_code_on_mutable_classes)
- Update imports and fix formatting

Reduces lint issues from 129 to 106. APK builds successfully (146 MB).
This commit is contained in:
vjrj 2026-03-11 23:45:06 +01:00
parent 270d9a569e
commit 8da3752193
12 changed files with 61 additions and 47 deletions

View file

@ -4,7 +4,7 @@ import 'package:meta/meta.dart';
class BasicLocation implements Comparable<BasicLocation> {
// static BasicLocation noLocation = new BasicLocation(lat: 0.0, lon: 0.0);
BasicLocation({required this.lat, required this.lon, this.description});
const BasicLocation({required this.lat, required this.lon, this.description});
BasicLocation.fromJson(Map<String, dynamic> json)
: lat = (json['lat'] as num).toDouble(),

View file

@ -10,7 +10,7 @@ part 'fireNotification.g.dart';
@immutable
@JsonSerializable()
class FireNotification {
FireNotification(
const FireNotification(
{required this.id,
required this.lat,
required this.lon,

View file

@ -31,7 +31,11 @@ class FiresApi {
final Response<Map<String, dynamic>> response =
await _dio.post<Map<String, dynamic>>(url, data: params);
if (response.statusCode == 200) {
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
final Map<String, dynamic>? responseData = response.data;
if (responseData == null) {
throw Exception('Response data is null');
}
final Map<String, dynamic> data = responseData;
final Map<String, dynamic> dataData =
data['data'] as Map<String, dynamic>;
return dataData['userId'] as String;
@ -52,7 +56,11 @@ class FiresApi {
final Response<Map<String, dynamic>> response =
await _dio.get<Map<String, dynamic>>(url);
if (response.statusCode == 200) {
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
final Map<String, dynamic>? responseData = response.data;
if (responseData == null) {
throw Exception('Response data is null');
}
final Map<String, dynamic> data = responseData;
final Map<String, dynamic> dataData =
data['data'] as Map<String, dynamic>;
final List<dynamic> dataSubscriptions =
@ -96,7 +104,11 @@ class FiresApi {
final Response<Map<String, dynamic>> response =
await _dio.post<Map<String, dynamic>>(url, data: params);
if (response.statusCode == 200) {
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
final Map<String, dynamic>? responseData = response.data;
if (responseData == null) {
throw Exception('Response data is null');
}
final Map<String, dynamic> data = responseData;
final Map<String, dynamic> dataData =
data['data'] as Map<String, dynamic>;
return dataData['subsId'] as String;

View file

@ -6,9 +6,10 @@ import '../objectIdUtils.dart';
part 'yourLocation.g.dart';
@immutable
@JsonSerializable()
class YourLocation {
YourLocation(
const YourLocation(
{required this.id,
required this.lat,
required this.lon,
@ -24,10 +25,10 @@ class YourLocation {
final ObjectId id;
final double lat;
final double lon;
String description;
bool subscribed;
int distance;
int currentNumFires;
final String description;
final bool subscribed;
final int distance;
final int currentNumFires;
static YourLocation get noLocation {
_noLocation ??= YourLocation(id: ObjectId(), lat: 0.0, lon: 0.0);