我完全迷路了。
上周我在一個運行良好的專案中作業。
然后我開始著手另一個專案并將我的 Flutter 版本升級到最新版本
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[?] Flutter (Channel stable, 3.0.2, on macOS 12.3.1 21E258 darwin-x64, locale en-GB)
[?] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[?] Xcode - develop for iOS and macOS (Xcode 13.3)
[?] Chrome - develop for the web
[?] Android Studio (version 2021.1)
[?] VS Code (version 1.68.0)
[?] Connected device (5 available)
[?] HTTP Host Availability
今天我需要對上周的專案進行一些更改,突然發現專案有5個檔案有錯誤。
所有錯誤都與包 geocoder2 有關。
作為這里的示例,您有問題所在:
onSelected: (Place place) async {
FetchGeocoder fetchGeocoder =
await Geocoder2.getCoordinatesFromAddress(
address: place.description,
googleMapApiKey:
"A---");
var first = fetchGeocoder.results.first;
var lat = first.geometry.location.lat;
var lng = first.geometry.location.lng;
LatLng sitio = LatLng(lat, lng);
錯誤說Undefined class 'FetchGeocoder,以前沒有問題。
uj5u.com熱心網友回復:
根據pub.dev中的包版本,包開始重命名FetchGeocoder為GeoData從 version 開始1.0.4,這是 pub.dev 中最新版本的最新版本:
GeoData data = await Geocoder2.getDataFromAddress(
address: "277 Bedford Ave, Brooklyn, NY 11211, USA",
googleMapApiKey: "GOOGLE_MAP_API_KEY",
);
//Formated Address
print(data.address);
//City Name
print(data.city);
//Country Name
print(data.country);
//Country Code
print(data.countryCode);
//Latitude
print(data.latitude);
//Longitude
print(data.longitude);
//Postal Code
print(data.postalCode);
//State
print(data.state);
//Street Number
print(data.street_number);
注意:這個問題是包作者的一個錯誤,因為對于重大更改,主要版本號應該被更改,并且檔案應該包含一個遷移部分。
因為作者只是更改了版本中的補丁號,所以它變成1.0.4了 from1.0.3而不是2.0.0正確地使用^sign in撰寫版本pubspec.yaml,Flutter 會自動在新的主要版本包之前拉取最新版本,這就是導致問題的原因為你而無需改變任何東西。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/491018.html
標籤:扑
下一篇:錯誤:[cloud_firestore/unknown]將FieldPath.of()用于包含“~*/[]”的欄位名稱
