【发布时间】:2021-12-30 11:02:23
【问题描述】:
今天我在测试我的应用程序的新功能时遇到了这个错误
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 会将我转发到名为“binding.dart”的类并标记completer.complete(reply);。但我不知道,它会对我说什么。我用于分享功能的包是this
【问题讨论】:
-
强制停止正在运行的应用程序,执行
flutter pub get,invalidate cache & restart。 -
第二步怎么做?
-
假设您使用的是
Android Studio,请转到pubspec.yaml& 点击Pub get,如果使用的是VSCode,则使用终端中的命令。 -
您在什么设备上运行应用程序?
-
我使用 chrome (Web),但使用的是 Iphone X