Home > Net >  LateError (LateInitializationError: Field '_state@590051772' has not been initialized.)
LateError (LateInitializationError: Field '_state@590051772' has not been initialized.)

Time:05-12

I don't understand why I'm catching an error in _mapController:

final MapController _mapController = MapController();

  @override
  void initState() {
    super.initState();
    _mapController.move(widget.latLng, _mapController.zoom);
  }

CodePudding user response:

I don't know but try like this ? :

  late MapController _mapController;

  @override
  void initState() {
    _mapController = MapController();
    _mapController.move(widget.latLng, _mapController.zoom);
    super.initState();
  }

CodePudding user response:

Try below code

MapController? _mapController;
//or try this-> MapController _mapController;

  @override
  void initState() {
    super.initState();
    _mapController.move(widget.latLng, _mapController.zoom);
  }
  • Related