当我想从 ListView 中提取数据时出现一些错误
I have some errors when i want to pull data from ListView
我想从 ListView 中提取数据时出现一些错误
错误如下:
constraints: MISSING
semantic boundary
size: MISSING
═══════════════════════════════════════════ ═══════════════════════════════════
════════渲染库捕获异常════════════════════════════════ ═
RenderBox 未布局:RenderRepaintBoundary#f3b69 NEEDS-LAYOUT NEEDS-PAINT
'package:flutter/src/rendering/box.dart':
package:flutter/…/rendering/box.dart:1
断言失败:第 1982 行第 12 行:'hasSize'
相关的 error-causing 小部件是
柱子
lib\…\hotel\hotel5yildiz.dart:41
══════════════════════════════════════════════════ ══════════════════════════════
在 2.713 毫秒内重新加载 706 个库中的 1 个。
I/flutter ( 9320): 4.3
W/System ( 9320): 忽略 header X-Firebase-Locale 因为它的值为 null。
D/FirebaseAuth( 9320): 通知 id 令牌监听器关于用户 (wzpAI4NY7wbpkrLsEVXMDU0kjAl2)。
这是代码
Scaffold(
appBar: appbarekle(context, "5 Yıldızlı Hoteller"),
backgroundColor: Color(0xffE7EEF5),
body: SingleChildScrollView(
child: Column(children: [
SizedBox(
height: 40,
),
Column(
children: [
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: kategoriRef.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> asyncSnapshot) {
if (!asyncSnapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
} else {
var querySnappshot = asyncSnapshot.data;
var hoteller = querySnappshot!.docs;
var mapdata = hoteller.forEach((doc) async {
var veri = doc.data() as Map<String, dynamic>;
hotel5yildiz.add(veri);
});
print(hotel5yildiz[0]["puan"]);
return ListView.builder(
itemCount: hotel5yildiz.length,
itemBuilder: (context, index) {
return hotelekle(
hotel5yildiz[index]["fotograf"],
hotel5yildiz[index]["adi"],
hotel5yildiz[index]["puan"]);
});
}
},
),
),
],
),
]),
),
),
您使用的是 SingleChildScrollView,但是在您的一个子 Columns 中,您使用 Expanded
包装了一些小部件
您需要为小部件提供垂直约束,因此它们的高度有限
您只需删除展开的小部件即可实现此目的
我想从 ListView 中提取数据时出现一些错误
错误如下:
constraints: MISSING
semantic boundary
size: MISSING
═══════════════════════════════════════════ ═══════════════════════════════════
════════渲染库捕获异常════════════════════════════════ ═ RenderBox 未布局:RenderRepaintBoundary#f3b69 NEEDS-LAYOUT NEEDS-PAINT 'package:flutter/src/rendering/box.dart': package:flutter/…/rendering/box.dart:1 断言失败:第 1982 行第 12 行:'hasSize'
相关的 error-causing 小部件是 柱子 lib\…\hotel\hotel5yildiz.dart:41 ══════════════════════════════════════════════════ ══════════════════════════════ 在 2.713 毫秒内重新加载 706 个库中的 1 个。 I/flutter ( 9320): 4.3 W/System ( 9320): 忽略 header X-Firebase-Locale 因为它的值为 null。 D/FirebaseAuth( 9320): 通知 id 令牌监听器关于用户 (wzpAI4NY7wbpkrLsEVXMDU0kjAl2)。
这是代码
Scaffold(
appBar: appbarekle(context, "5 Yıldızlı Hoteller"),
backgroundColor: Color(0xffE7EEF5),
body: SingleChildScrollView(
child: Column(children: [
SizedBox(
height: 40,
),
Column(
children: [
Expanded(
child: StreamBuilder<QuerySnapshot>(
stream: kategoriRef.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> asyncSnapshot) {
if (!asyncSnapshot.hasData) {
return Center(
child: CircularProgressIndicator(),
);
} else {
var querySnappshot = asyncSnapshot.data;
var hoteller = querySnappshot!.docs;
var mapdata = hoteller.forEach((doc) async {
var veri = doc.data() as Map<String, dynamic>;
hotel5yildiz.add(veri);
});
print(hotel5yildiz[0]["puan"]);
return ListView.builder(
itemCount: hotel5yildiz.length,
itemBuilder: (context, index) {
return hotelekle(
hotel5yildiz[index]["fotograf"],
hotel5yildiz[index]["adi"],
hotel5yildiz[index]["puan"]);
});
}
},
),
),
],
),
]),
),
),
您使用的是 SingleChildScrollView,但是在您的一个子 Columns 中,您使用 Expanded
包装了一些小部件您需要为小部件提供垂直约束,因此它们的高度有限
您只需删除展开的小部件即可实现此目的