gpt4 book ai didi

flutter - 未实现的缺失静态目标处理,Flutter

转载 作者:行者123 更新时间:2023-12-03 03:15:13 25 4
gpt4 key购买 nike

我正在编写我的 Flutter 代码,但我不断收到未实现处理缺少静态目标的错误。没有其他错误提示,所以我不知道为什么会出现此错误,而且我无法调试它。我得到的错误是:

══════ Exception caught by widgets library ═══════════════════════════════════
The following _CompileTimeError was thrown building Wrapper(dirty, dependencies: [InheritedProvider<User>], state: _Wrapper#576d6):
Unimplemented handling of missing static target

The relevant error-causing widget was
Wrapper
lib\main.dart:28
When the exception was thrown, this was the stack
#0 StatefulElement.build
package:flutter/…/widgets/framework.dart:4334
#1 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4223
#2 Element.rebuild
package:flutter/…/widgets/framework.dart:3947
#3 StatefulElement.update
package:flutter/…/widgets/framework.dart:4413
#4 Element.updateChild
package:flutter/…/widgets/framework.dart:2977
...
════════════════════════════════════════════════════════════════════════════════
Reloaded 5 of 544 libraries in 350ms.

════════ Exception caught by widgets library ═══════════════════════════════════
Unimplemented handling of missing static target
The relevant error-causing widget was
Wrapper

我的代码是:

import 'package:sociagrowapp/models/user.dart';
import 'package:sociagrowapp/HomePages/Home.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sociagrowapp/Authenticate/authenticate.dart';
//import 'package:package_info/package_info.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:sociagrowapp/services/firestore.dart';
import 'package:http/http.dart' as http;

class Wrapper extends StatefulWidget {
@override
createState() => _Wrapper();
}

class _Wrapper extends State<Wrapper> {
@override
Widget build(BuildContext context) {
Future getversionnumber() async {

var data = http.get('https://sociagrow.com/version.html');
print(data);
return data;
}

return FutureBuilder(
future: getversionnumber(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
final user = Provider.of<User>(context);
print(user);
var version = snapshot.data;
// return either the Home or Authenticate widget
if (version == false) {
return Text('Oh no You need to update');
} else {
if (user == null) {
print('Should Changed 3');
return Scaffold(body: Authenticate());
} else {
return PageData();
}
}
} else {
return SpinKitThreeBounce(
color: Colors.blue,
);
}
});
}
}

奇怪的是,当我在 visual studio code 中调试它时,它运行了,但是当我重新保存并热重载它时,我得到了这个错误。问题不在 http.get() 中,因为我在其他 future 功能和 firestore 中也遇到了错误。真的很奇怪,虽然我没有遇到过这种类型的错误,而且我在互联网上找不到任何关于这个错误的信息。

最佳答案

可能是热重载缓存导致了这个问题,我刚遇到同样的问题,我通过停止项目然后重新启动来修复它。

enter image description here

关于flutter - 未实现的缺失静态目标处理,Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60878860/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com