我只是在学习颤振,我发现了问题。我无法从 firebase 检索数据,以前我可以使用相同的代码检索数据,但现在我不能。我发现我发现了下面列出的错误。 这是怎么发生的?而在此之前,它不是。希望有人能帮帮我
这是我的代码
``` StreamBuilder(
stream: dbRef.child("Data").onValue,
builder: (context, snapshot) {
if (snapshot.hasData &&
!snapshot.hasError &&
snapshot.data.snapshot.value != null) {
return Column(
children: <Widget>[
Container(
height: size.height * 1,
child: Stack(
children: <Widget>[
Positioned(
height: 40,
bottom: 520,
left: 0,
right: 0,
child: Container(
margin: EdgeInsets.symmetric(
horizontal: kDefaultPadding),
padding: EdgeInsets.symmetric(
horizontal: kDefaultPadding),
height: 10,
decoration: BoxDecoration(
color: Colors.cyan,
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(
offset: Offset(0, 10),
blurRadius: 50,
color: kPrimaryColor.withOpacity(0.5),
),
],
),
child: Center(
child: Text("PLANT MOISTURE CONTROLLER",
style: TextStyle(fontSize: 18)),
),
)),],))],)}}) ```
这是错误:
答案 0 :(得分:0)
你需要在加载数据时返回一些小部件,例如:
StreamBuilder(
stream: dbRef.child("Data").onValue,
builder: (context, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
return Container(child: Text('real content'));
});