'Flutter wrap textview right overflow error
I have a problem about wrap text overflow right. I know that I should use flexible but where? This is my flutter code. I want to solve right overflow error.
class PhotosList extends StatelessWidget {
const PhotosList({Key? key, required this.photos}) : super(key: key);
final List<Photo> photos;
@override
Widget build(BuildContext context) {
return Container(child: LayoutBuilder(
builder: (context, constraints) {
//UI for dekstop
if (constraints.maxWidth > 1200) {
return ListView.builder(
padding: EdgeInsets.all(20),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: photos.length,
itemBuilder: (context, index) {
return ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
spreadRadius: 0.0,
blurRadius: 1.0,
offset: Offset(0.0, 1.0))
]),
padding: EdgeInsets.all(10),
child: Row(
children: [
Container(child: Image.network(photos[index].activityPhoto,
width: 200,
height: 100,),
),
SizedBox(width: 20,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(photos[index].activityDate),
Text(photos[index].activityName),
Text(photos[index].activityDetails),
],),
],
)),
);
});
Target of this code show a list with a design. 1 image and 3 texts.
Solution 1:[1]
Wrap your Column of Text which is throwing overflow error with Flexible widget:
Code:
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("photos[index].activityDate"),
Text("photos[index].activityName"),
Text("photos[index].activityDetails"),
],
),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pacific |
