错误:MissingPluginException(在channel-plugins.flutter.io/share上



今天我在测试应用的新功能时遇到了这个错误

at Object.throw_ [as throw] (http://localhost:17968/dart_sdk.js:5063:11)
at MethodChannel._invokeMethod (http://localhost:17968/packages/flutter/src/services/restoration.dart.lib.js:1555:21)
at _invokeMethod.next (<anonymous>)
at http://localhost:17968/dart_sdk.js:40192:33
at _RootZone.runUnary (http://localhost:17968/dart_sdk.js:40062:59)
at _FutureListener.thenAwait.handleValue (http://localhost:17968/dart_sdk.js:34983:29)
at handleValueCallback (http://localhost:17968/dart_sdk.js:35551:49)
at Function._propagateToListeners (http://localhost:17968/dart_sdk.js:35589:17)
at _Future.new.[_completeWithValue] (http://localhost:17968/dart_sdk.js:35437:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:17968/dart_sdk.js:35458:35)
at Object._microtaskLoop (http://localhost:17968/dart_sdk.js:40330:13)
at _startMicrotaskLoop (http://localhost:17968/dart_sdk.js:40336:13)
at http://localhost:17968/dart_sdk.js:35811:9

我在谷歌上搜索了一下,发现了另一个关于这个问题的论坛条目。他们说,错误出现了,但确认了一次热装。他们说我想停止应用程序并重新运行它,但它并不能修复错误。该代码来自教程,所有操作都很好。这是我的代码:

import 'package:flutter/material.dart';
import 'package:share/share.dart';
class DetailScreen extends StatelessWidget {
const DetailScreen(this.title, this.done);
final String title;
final bool done;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: done ? Colors.green : Colors.red,
appBar: AppBar(
title: Text('Detail Screen'),
backgroundColor: Colors.transparent,
),
body: Padding(
padding: EdgeInsets.symmetric(vertical: 70),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.all(20),
alignment: Alignment.center,
child: Text(
done ? 'Das hast du schon erledigt:' : 'Das musst du noch machen:',
style: TextStyle(fontSize: 20, color: Colors.white), textAlign: TextAlign.center,))
),
Expanded(
child: Container(
alignment: Alignment.center,
child: Text(title, style: TextStyle(fontSize: 50, color: Colors.white)))
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
IconButton(
iconSize: 60,
onPressed: () {
String message;
if (done) {
message = 'Ich habe folgendes Todo erledigt: ' + title;
} else {
message = 'Das muss noch erledigt werden: ' + title;
}
Share.share(message);
},
icon: Icon(Icons.share, color: Colors.white),
),
IconButton(
iconSize: 60,
onPressed: () => Navigator.pop(context),
icon: Icon(done ? Icons.check : Icons.close, color: Colors.white),
),
],
),
),
],
),
),
);
}
}

哦,有时IntelliJ将我转发到名为"的类;装帧;并标记线CCD_ 1。但我不知道,它会告诉我什么。我用于共享功能的包是这个

当我在项目上添加了一个新的依赖项时,遇到了这个问题,这就是我解决的方法。

停止应用程序
运行flutter clean
执行flutter pub get
启动应用程序,错误消失。

当您提到时

我在谷歌上搜索了一下,发现了另一个关于这个问题的论坛条目。他们说,错误出现了,但确认了一次热装。他们说我想停止应用程序并重新运行它,但它并不能修复错误。该代码来自教程,所有操作都很好。

不适用于您尝试运行flutter clean&flutter pub获取

最新更新