fix: lazy initialize YourLocation.noLocation to prevent LateInitializationError
The static field 'noLocation' was never initialized after removing the _initNoLocation() function. Changed to a lazy getter that initializes on first access to prevent runtime crash.
This commit is contained in:
parent
35d6b33c5f
commit
948a609619
1 changed files with 6 additions and 1 deletions
|
|
@ -29,7 +29,12 @@ class YourLocation {
|
|||
int distance;
|
||||
late int currentNumFires;
|
||||
|
||||
static late final YourLocation noLocation;
|
||||
static YourLocation get noLocation {
|
||||
_noLocation ??= YourLocation(id: ObjectId(), lat: 0.0, lon: 0.0);
|
||||
return _noLocation!;
|
||||
}
|
||||
|
||||
static YourLocation? _noLocation;
|
||||
static const int? withoutStats = null;
|
||||
|
||||
Map<String, dynamic> toJson() => _$YourLocationToJson(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue