Im using some code from a tutorial but putting it in my own app. I cant figure out the next warning and how to solve:
LateInitializationError: Field ‘_durationRemaining@585382383’ has not been initialized.
The code(piece of the whole code) where this error is from is:
late MapBoxNavigation _directions;
late MapBoxOptions _options;
bool _isMultipleStop = false;
late double _distanceRemaining, _durationRemaining;
late MapBoxNavigationViewController _controller;
bool _routeBuilt = false;
bool _isNavigating = false;
@override
void initState() {
super.initState();
initialize();
}
The error is about the rule:
late double _distanceRemaining, _durationRemaining;
Am i doing something wrong? Maybe because i have 2 fields behind the late double and not the right way?
If i delete the Late in front of double, then get this errors:
lib/main.dart:42:10: Error: Field ‘_distanceRemaining’ should be initialized because its type ‘double’ doesn’t allow null. double _distanceRemaining, _durationRemaining; ^^^^^^^^^^^^^^^^^^ lib/main.dart:42:30: Error: Field ‘_durationRemaining’ should be initialized because its type ‘double’ doesn’t allow null. double _distanceRemaining, _durationRemaining;