从一开始我就一直在使用Geocoder-0.1.2,但这并没有给我带来任何问题。我刚刚升级了Flutter,并且在运行项目时遇到此错误:
Compiler message:
file:///Users/alok/flutter/.pub-cache/hosted/pub.dartlang.org/geocoder-0.1.2/lib/services/d
istant_google.dart:38:56: Error: The argument type 'Utf8Decoder' can't be assigned to the
parameter type 'StreamTransformer<Uint8List, dynamic>'.
- 'Utf8Decoder' is from 'dart:convert'.
- 'StreamTransformer' is from 'dart:async'.
- 'Uint8List' is from 'dart:typed_data'.
Try changing the type of the parameter, or casting the argument to
'StreamTransformer<Uint8List, dynamic>'.
final responseBody = await response.transform(utf8.decoder).join();
^
Compiler failed on /Users/alok/MyProjects/newmonkapp/lib/main.dart
Error launching application on iPhone 7.
由于错误表明它在main.dart
中,所以没有与此相关的代码,因此我对它进行了两次检查。给你。
main.dart
import 'package:flutter/material.dart';
void main() => runApp(NewMonkApp());
class NewMonkApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("in the main builder");
return MaterialApp(
title: 'XYZ',
debugShowCheckedModeBanner: false,
theme: ThemeData(
backgroundColor: Color.fromRGBO(249, 249, 251, 1),
fontFamily: 'SF Pro',
primaryColor: Color.fromRGBO(253, 92, 99, 1),
textTheme: TextTheme(
headline: TextStyle(
fontSize: 34.0, fontWeight: FontWeight.bold,
color: Color.fromRGBO(64, 72, 82, 1)
)
)
),
initialRoute: "/",
routes: {
"/": (context) => InitPage(),
// "/": (context) => SearchFilterPage()
}
);
}
}
它退出应用程序。不知道问题是什么,我该如何解决。我试图用谷歌搜索它,似乎找不到更好的解决方案。任何帮助,将不胜感激。
Flutter Doctor结果:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.8.1-pre.44, on Mac OS X 10.14.5 18F132, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Chrome - develop for the web
[!] Android Studio (version 3.4)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (3 available)
! Doctor found issues in 1 category.
任何帮助将不胜感激。谢谢:)
答案 0 :(得分:0)
更改此行的最终响应=等待请求。 close()。
到
最终响应=等待request.close()。then((response){response.cast>()。transform(utf8.decoder).listen((content){return content;});});
这对我有用? 内部flutter插件,地理编码器和文件名distant_google.dart