找不到方法getAndroidDeviceInfo的实现

时间:2018-04-25 16:41:14

标签: dart flutter

我正在尝试在插件页面中运行此example 我收到此错误

I/flutter ( 3273): MissingPluginException(No implementation found for method getAndroidDeviceInfo on channel plugins.flutter.io/device_info)
I/flutter ( 3273): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:153:7)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #1      DeviceInfoPlugin.androidInfo (package:device_info/device_info.dart:25:35)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #2      _MyAppState.initPlatformState (/data/user/0/com.yourcompany.demos/cache/demosSWKRJL/demos/lib/main.dart:37:67)
I/flutter ( 3273): <asynchronous suspension>
I/flutter ( 3273): #3      _MyAppState.initState (/data/user/0/com.yourcompany.demos/cache/demosSWKRJL/demos/lib/main.dart:29:5)
I/flutter ( 3273): #4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3734:58)
I/flutter ( 3273): #5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600:5)
I/flutter ( 3273): #6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890:14)
I/flutter ( 3273): #7      Element.updateChild (package:flutter/src/widgets/framework.dart:2693:12)
I/flutter ( 3273): #8      RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:852:16)
I/flutter ( 3273): #9      RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:823:5)
I/flutter ( 3273): #10     RenderObje

3 个答案:

答案 0 :(得分:12)

这不是错误

这与平台特定的编码无关,如@challenget回答

  • 您只需要重新构建并再次运行该应用程序,即可添加flutter-plugin并使其正常工作。

热重启将不起作用

:hearts [这是功能请求[btw]

答案 1 :(得分:1)

DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
  AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
} else if (Platform.isIOS) {
  IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
}

您需要判断设备。

答案 2 :(得分:-1)

停止应用程序并重新启动构建。这对我有用。