如何解决“”不是'Map <string,dynamic =“”>类型的子类型?

时间:2019-01-27 20:52:35

标签: dart flutter

你好吗。颤振代码是地图线显示错误。这条线是。谢谢您的时间。我不明白。

这是错误的:

import UIKit
import CoreLocation
class ViewController: UIViewController,CLLocationManagerDelegate {
    var locationManager = CLLocationManager()
    var currentlocation:CLLocation!



    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
     //   authorizelocationstates()
    }

    func authorizelocationstates(){
        if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
            currentlocation = locationManager.location
            print(currentlocation)
        }
        else{
            // Note : This function is overlap permission
            //  locationManager.requestWhenInUseAuthorization()
           //  authorizelocationstates()
        }
    }
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        locationManager = manager
        // Only called when variable have location data
        authorizelocationstates()
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        // Get Location Permission one time only
        locationManager.requestWhenInUseAuthorization()
        // Need to update location and get location data in locationManager object with delegate
        locationManager.startUpdatingLocation()
        locationManager.startMonitoringSignificantLocationChanges()

    }

}

1 个答案:

答案 0 :(得分:2)

更改

Map carData={
'carModel':this.carModel,
'carColor':this.carColor
};

Map<String,dynamic>  carData={
'carModel':this.carModel,
'carColor':this.carColor
};