我在从模拟模型中获取数据时遇到问题,但得到错误代码:RenderBox未布局:RenderPointerListener#33496 relayoutBoundary=up15 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
我的模特. /models/messagemodel.dart
import 'package:flutter/material.dart';
class Message {
final String name;
final String message;
final String imageProfile;
final String date;
Message({
required this.name,
required this.message,
required this.imageProfile,
required this.date});
}
final List<Message> messages = [
Message(name: 'อลงกรณ์ ดอนสุวรรณ', message: "สอบถามตัวสินค้าหน่อยครับ", imageProfile:'https://i.pinimg.com/236x/cc/00/75/cc007582be734f3eb536e45006ba8ac1.jpg',date: '2023-05-31'),
Message(name: 'รัชนก ธานี', message: "สินค้ายังมีอยู่ไหมคะ", imageProfile:'https://blogs.jaidee-webdesign.com/wp-content/uploads/2021/09/253-2532493_thinking-man-png-free-download-transparent-png.png',date: '2023-05-30'),
Message(name: 'Gordon Ramsey', message: "Hello , I need to your product", imageProfile:'https://www.nicepng.com/png/detail/340-3400291_smiling-person-png-man-with-arms-crossed-png.png',date: '2023-05-29'),
];
字符串
这是我的视图页。/messageview.dart
import 'package:flutter/material.dart';
import 'package:rj38_seller/environment/themes.dart';
import 'package:rj38_seller/models/messagemodel.dart';
import 'package:rj38_seller/views/message/components/listmessage.dart';
class MessageView extends StatefulWidget {
const MessageView({super.key});
@override
State<MessageView> createState() => _MessageViewState();
}
class _MessageViewState extends State<MessageView> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Themes().backgroundTheme,
appBar: AppBar(
centerTitle: false,
titleSpacing: 0.0,
backgroundColor: Themes().white,
elevation: 0,
title: Transform(transform: Matrix4.translationValues(30.0, 0.0, 0.0),
child: Text('Message',style: TextStyle(color: Themes().black)))
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const ListView.builder(
itemCount: messages.length,
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(messages[index].imageProfile),
),
title: Text(messages[index].name),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(messages[index].message),
Text('Date: ${messages[index].date}'),
],
),
onTap: () {
// การทำงานเมื่อกดที่รายการข้อความ
// คุณสามารถเพิ่มโค้ดที่นี่เพื่อรายละเอียดเพิ่มเติมหากต้องการ
},
),
);
},
),
],
),
),
);
}
}
型
错误enter image description here
怎么修谢谢先生
4条答案
按热度按时间zed5wv101#
您在
Scrollable
小部件中放置了一个无限高的子小部件,导致了此错误。要解决此问题,您可以尝试以下操作:SingleChildScrollView
和Column
小部件,仅保留ListView
小部件,使整个页面仅由ListView.builder
组成。或
shrinkWrap: true
和physics: const NeverScrollableScrollPhysics()
属性添加到ListView
小部件,这样您就可以在Column
中使用其他小部件沿着ListView
。必须从ListView.builder
中删除const
标记。希望这对你有帮助!
6qftjkof2#
删除SingleChildScrollView和列小部件,只需添加ListView.Buidler在脚手架体像下面的代码:
字符串
7gcisfzg3#
删除SingleChildScrollView和Column小部件将有所帮助。
zc0qhyus4#
enter image description here
我删除了CircleAvatar并开始工作,但是CircleAvatar有什么问题吗