flutter - Flutter:小部件库错误捕获的异常
问题描述
在我正在开发的应用程序中,我不断收到以下错误。错误之后是它指向的代码部分。
Exception caught by widgets library ══════════════════════════════════
'package:flutter/src/painting/_network_image_io.dart': Failed assertion: line 25 pos 14:
'url != null': is not true.
The relevant error-causing widget was
Homepage
lib/…/LandingPage/landingServices.dart:359
** 第 359 行在 child: Homepage() 下方,我在之前和之后添加了代码。══════════════════════════════════════════════════ ══════════════════════════════
.createUserCollection(context, {
'userpassword': userPasswordController.text,
'useruid': Provider.of<Authentication>(context,
listen: false)
.getUserUid,
'useremail': userEmailController.text,
'username': userNameController.text,
'userimage': Provider.of<LandingUtils>(context,
listen: false)
.getUserAvatarUrl,
});
}).whenComplete(() {
Navigator.pushReplacement(
context,
PageTransition(
child: Homepage(),
type:
PageTransitionType.bottomToTop));
我的主页代码在这里:
class Homepage extends StatefulWidget {
@override
_HomepageState createState() => _HomepageState();
}
class _HomepageState extends State<Homepage> {
ConstantColors constantColors = ConstantColors();
final PageController homepageController = PageController();
int pageIndex = 0;
@override
void initState() {
Provider.of<FirebaseOperations>(context, listen: false)
.initUserData(context);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: constantColors.darkColor,
body: PageView(
controller: homepageController,
children: [Feed(), Chatroom(), Profile()],
physics: NeverScrollableScrollPhysics(),
onPageChanged: (page) {
setState(() {
pageIndex = page;
});
},
),
bottomNavigationBar:
Provider.of<HomepageHelpers>(context, listen: false)
.bottomNavBar(context, pageIndex, homepageController));
}
}
任何想法?我想不通。谢谢!
解决方案
只需将上下文更改为homepageController右侧的内容.. 相信我,它肯定会起作用..
bottomNavigationBar:
Provider.of<HomepageHelpers>(context, listen: false)
.bottomNavBar(pageIndex, homepageController, context));
}
}
推荐阅读
- node.js - 如何让编译器知道我在哪里导入
- javascript - 角度:无错误但未在材料表中显示数据
- angular - 查询字符串格式传递用户名和密码
- javascript - jQuery .toggleClass() 在打开类后不会关闭类
- azure - 无法将 Azure-DevOps 与 Azure 容器注册表连接
- php - 在查找数组数据上实现的 Foreach 只找到一个数据
- bash - 如何将管道阶段变量传递给makefile
- html - 如何通过 html/css 实现这样的元素
- kubernetes - Cluster-autoscaler 不会触发 Daemonset 部署的扩展
- r - R 检查数据框中是否存在元素并返回其索引