refactor: continue lint cleanup - 96 more issues fixed
- Add @immutable to classes with ==/hashCode (homePage, basicLocation, fireNotification, yourLocation, monitoredAreas) - Fix camel_case_types (genericMap → GenericMap) - Fix avoid_dynamic_calls (firesApi - typed responses) - Fix use_build_context_synchronously (locationUtils) - Fix always_put_control_body_on_new_line (4 reducers) - Fix always_specify_types (placesAutocompleteUtils, reducers) - Fix eol_at_end_of_file (4 files) - Fix prefer_function_declarations_over_variables (introPage) - Fix flutter_style_todos (fireMapReducer) Build: APK generated, 0 errors, 0 warnings
This commit is contained in:
parent
862d423f6b
commit
68ad4adbcf
23 changed files with 118 additions and 95 deletions
|
|
@ -1,5 +1,7 @@
|
|||
class BasicLocation implements Comparable<BasicLocation> {
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@immutable
|
||||
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});
|
||||
|
|
@ -18,7 +20,8 @@ class BasicLocation implements Comparable<BasicLocation> {
|
|||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object o) => o is BasicLocation && o.lat == lat && o.lon == lon;
|
||||
bool operator ==(Object o) =>
|
||||
o is BasicLocation && o.lat == lat && o.lon == lon;
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
enum FalsePositiveType { industry, controled, falsealarm }
|
||||
enum FalsePositiveType { industry, controled, falsealarm }
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:objectid/objectid.dart';
|
||||
|
||||
import '../objectIdUtils.dart';
|
||||
|
||||
part 'fireNotification.g.dart';
|
||||
|
||||
@JsonSerializable(nullable: false)
|
||||
@immutable
|
||||
@JsonSerializable()
|
||||
class FireNotification {
|
||||
|
||||
FireNotification(
|
||||
{required this.id,
|
||||
required this.lat,
|
||||
|
|
|
|||
|
|
@ -28,9 +28,11 @@ class FiresApi {
|
|||
};
|
||||
final String url = '${state.firesApiUrl}mobile/users';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.post(url, data: params);
|
||||
final Response<Map<String, dynamic>> response =
|
||||
await _dio.post<Map<String, dynamic>>(url, data: params);
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['data']['userId'] as String;
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
return data['data']['userId'] as String;
|
||||
} else {
|
||||
throw Exception('Unexpected error on create user');
|
||||
}
|
||||
|
|
@ -45,18 +47,25 @@ class FiresApi {
|
|||
final String url =
|
||||
'${state.firesApiUrl}mobile/subscriptions/all/$apiKey/$mobileToken';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.get(url);
|
||||
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> dataData =
|
||||
data['data'] as Map<String, dynamic>;
|
||||
final List<dynamic> dataSubscriptions =
|
||||
response.data['data']['subscriptions'] as List<dynamic>;
|
||||
dataData['subscriptions'] as List<dynamic>;
|
||||
final List<YourLocation> subscribed = <YourLocation>[];
|
||||
for (int i = 0; i < dataSubscriptions.length; i++) {
|
||||
final Map<String, dynamic> el =
|
||||
dataSubscriptions[i] as Map<String, dynamic>;
|
||||
final double lat = (el['location']['lat'] as num).toDouble();
|
||||
final double lon = (el['location']['lon'] as num).toDouble();
|
||||
final Map<String, dynamic> location =
|
||||
el['location'] as Map<String, dynamic>;
|
||||
final double lat = (location['lat'] as num).toDouble();
|
||||
final double lon = (location['lon'] as num).toDouble();
|
||||
final Map<String, dynamic> id = el['_id'] as Map<String, dynamic>;
|
||||
subscribed.add(YourLocation(
|
||||
id: objectIdFromJson(el['_id']['_str'] as String),
|
||||
id: objectIdFromJson(id['_str'] as String),
|
||||
lat: lat,
|
||||
lon: lon,
|
||||
subscribed: true,
|
||||
|
|
@ -82,9 +91,11 @@ class FiresApi {
|
|||
};
|
||||
final String url = '${state.firesApiUrl}mobile/subscriptions';
|
||||
try {
|
||||
final Response<dynamic> response = await _dio.post(url, data: params);
|
||||
final Response<Map<String, dynamic>> response =
|
||||
await _dio.post<Map<String, dynamic>>(url, data: params);
|
||||
if (response.statusCode == 200) {
|
||||
return response.data['data']['subsId'] as String;
|
||||
final Map<String, dynamic> data = response.data as Map<String, dynamic>;
|
||||
return data['data']['subsId'] as String;
|
||||
} else {
|
||||
throw Exception('Unexpected error on subscribe');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:objectid/objectid.dart';
|
||||
|
||||
import '../objectIdUtils.dart';
|
||||
|
||||
part 'yourLocation.g.dart';
|
||||
|
||||
@immutable
|
||||
@JsonSerializable()
|
||||
class YourLocation {
|
||||
YourLocation(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue