fix(control-panel): make position model fields nullable to prevent null cast crash
This commit is contained in:
@@ -36,11 +36,11 @@ abstract class LatestPositionsItemResponseModel
|
||||
required int positionDate,
|
||||
int? positionDateOriginal,
|
||||
String? frequentPlaceName,
|
||||
required String message,
|
||||
required List<LatestPositionsNetworkResponseModel> networks,
|
||||
required bool ignore,
|
||||
required bool suspect,
|
||||
required bool frequentPlace,
|
||||
@Default('') String message,
|
||||
@Default([]) List<LatestPositionsNetworkResponseModel> networks,
|
||||
@Default(false) bool ignore,
|
||||
@Default(false) bool suspect,
|
||||
@Default(false) bool frequentPlace,
|
||||
}) = _LatestPositionsItemResponseModel;
|
||||
|
||||
factory LatestPositionsItemResponseModel.fromJson(
|
||||
@@ -110,9 +110,9 @@ extension LatestPositionsAddressResponseModelMapper
|
||||
abstract class LatestPositionsNetworkResponseModel
|
||||
with _$LatestPositionsNetworkResponseModel {
|
||||
const factory LatestPositionsNetworkResponseModel({
|
||||
required String SSID,
|
||||
required String BSSID,
|
||||
required String signal,
|
||||
@Default('') String SSID,
|
||||
@Default('') String BSSID,
|
||||
@Default('') String signal,
|
||||
}) = _LatestPositionsNetworkResponseModel;
|
||||
|
||||
factory LatestPositionsNetworkResponseModel.fromJson(
|
||||
|
||||
@@ -507,7 +507,7 @@ return $default(_that.id,_that.deviceIdentificator,_that.latitude,_that.longitud
|
||||
@JsonSerializable()
|
||||
|
||||
class _LatestPositionsItemResponseModel implements LatestPositionsItemResponseModel {
|
||||
const _LatestPositionsItemResponseModel({required this.id, required this.deviceIdentificator, required this.latitude, required this.longitude, required this.hpe, this.ncell, required this.type, this.steps, this.address, required this.createdAt, required this.positionDate, this.positionDateOriginal, this.frequentPlaceName, required this.message, required final List<LatestPositionsNetworkResponseModel> networks, required this.ignore, required this.suspect, required this.frequentPlace}): _networks = networks;
|
||||
const _LatestPositionsItemResponseModel({required this.id, required this.deviceIdentificator, required this.latitude, required this.longitude, required this.hpe, this.ncell, required this.type, this.steps, this.address, required this.createdAt, required this.positionDate, this.positionDateOriginal, this.frequentPlaceName, this.message = '', final List<LatestPositionsNetworkResponseModel> networks = const [], this.ignore = false, this.suspect = false, this.frequentPlace = false}): _networks = networks;
|
||||
factory _LatestPositionsItemResponseModel.fromJson(Map<String, dynamic> json) => _$LatestPositionsItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@@ -523,17 +523,17 @@ class _LatestPositionsItemResponseModel implements LatestPositionsItemResponseMo
|
||||
@override final int positionDate;
|
||||
@override final int? positionDateOriginal;
|
||||
@override final String? frequentPlaceName;
|
||||
@override final String message;
|
||||
@override@JsonKey() final String message;
|
||||
final List<LatestPositionsNetworkResponseModel> _networks;
|
||||
@override List<LatestPositionsNetworkResponseModel> get networks {
|
||||
@override@JsonKey() List<LatestPositionsNetworkResponseModel> get networks {
|
||||
if (_networks is EqualUnmodifiableListView) return _networks;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_networks);
|
||||
}
|
||||
|
||||
@override final bool ignore;
|
||||
@override final bool suspect;
|
||||
@override final bool frequentPlace;
|
||||
@override@JsonKey() final bool ignore;
|
||||
@override@JsonKey() final bool suspect;
|
||||
@override@JsonKey() final bool frequentPlace;
|
||||
|
||||
/// Create a copy of LatestPositionsItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -1099,12 +1099,12 @@ return $default(_that.SSID,_that.BSSID,_that.signal);case _:
|
||||
@JsonSerializable()
|
||||
|
||||
class _LatestPositionsNetworkResponseModel implements LatestPositionsNetworkResponseModel {
|
||||
const _LatestPositionsNetworkResponseModel({required this.SSID, required this.BSSID, required this.signal});
|
||||
const _LatestPositionsNetworkResponseModel({this.SSID = '', this.BSSID = '', this.signal = ''});
|
||||
factory _LatestPositionsNetworkResponseModel.fromJson(Map<String, dynamic> json) => _$LatestPositionsNetworkResponseModelFromJson(json);
|
||||
|
||||
@override final String SSID;
|
||||
@override final String BSSID;
|
||||
@override final String signal;
|
||||
@override@JsonKey() final String SSID;
|
||||
@override@JsonKey() final String BSSID;
|
||||
@override@JsonKey() final String signal;
|
||||
|
||||
/// Create a copy of LatestPositionsNetworkResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
||||
@@ -42,17 +42,19 @@ _LatestPositionsItemResponseModel _$LatestPositionsItemResponseModelFromJson(
|
||||
positionDate: (json['positionDate'] as num).toInt(),
|
||||
positionDateOriginal: (json['positionDateOriginal'] as num?)?.toInt(),
|
||||
frequentPlaceName: json['frequentPlaceName'] as String?,
|
||||
message: json['message'] as String,
|
||||
networks: (json['networks'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => LatestPositionsNetworkResponseModel.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
ignore: json['ignore'] as bool,
|
||||
suspect: json['suspect'] as bool,
|
||||
frequentPlace: json['frequentPlace'] as bool,
|
||||
message: json['message'] as String? ?? '',
|
||||
networks:
|
||||
(json['networks'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) => LatestPositionsNetworkResponseModel.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
const [],
|
||||
ignore: json['ignore'] as bool? ?? false,
|
||||
suspect: json['suspect'] as bool? ?? false,
|
||||
frequentPlace: json['frequentPlace'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LatestPositionsItemResponseModelToJson(
|
||||
@@ -101,9 +103,9 @@ Map<String, dynamic> _$LatestPositionsAddressResponseModelToJson(
|
||||
_LatestPositionsNetworkResponseModel
|
||||
_$LatestPositionsNetworkResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_LatestPositionsNetworkResponseModel(
|
||||
SSID: json['SSID'] as String,
|
||||
BSSID: json['BSSID'] as String,
|
||||
signal: json['signal'] as String,
|
||||
SSID: json['SSID'] as String? ?? '',
|
||||
BSSID: json['BSSID'] as String? ?? '',
|
||||
signal: json['signal'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LatestPositionsNetworkResponseModelToJson(
|
||||
|
||||
Reference in New Issue
Block a user