BoxConstraints has a negative minimum width.

1,489 views
Skip to first unread message

Raman Plaha

unread,
Feb 16, 2021, 7:02:45 AM2/16/21
to Flutter Development (flutter-dev)
hi everyone, I am facing this issue from yesterday,  I have added  flutter_swiper: ^1.1.6 for carousel but getting this error 
my code-

Container imgcarousel() {
return jobroleObj == null
? Container(
height: 160,
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return Image.asset(
"assets/defimg.jpg",
fit: BoxFit.contain,
);
},
indicatorLayout: PageIndicatorLayout.COLOR,
autoplay: false,
itemCount: 1,
pagination: new SwiperPagination(),
//control: new SwiperControl(),
))
: Container(
height: 160,
constraints: BoxConstraints(
minHeight: 150, minWidth: double.infinity, maxHeight: 160),
child: Swiper(
itemBuilder: (BuildContext context, int index) {
if (jobroleObj != null) {
if (jobroleObj.ImageUrl != null) {
return Container( width: 160,
child: Image.network(
jobroleObj.ImageUrl,
fit: BoxFit.contain,
errorBuilder: (BuildContext context, Object exception,
StackTrace stackTrace) {
return Container( width: 160,
child: Image.asset("assets/defimg.jpg",
fit: BoxFit.contain),
);
},
),
);
} else {
return Image.asset("assets/defimg.jpg",
fit: BoxFit.contain);
}
} else {
return Image.asset("assets/defimg.jpg", fit: BoxFit.contain);
}
},
indicatorLayout: PageIndicatorLayout.COLOR,
autoplay: false,
itemCount: jobroleObj.ImageUrl == null ? 0 : jobroleObj.ImageUrl,
pagination: new SwiperPagination(),
//control: new SwiperControl(),
));
}

any help

Raman Plaha

unread,
Feb 16, 2021, 7:11:44 AM2/16/21
to Flutter Development (flutter-dev)
error is --
BoxConstraints has a negative minimum width.
The relevant error-causing widget was:
  Swiper file:///F:/FlutterProjects/xyz.dart

--
You received this message because you are subscribed to a topic in the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flutter-dev/PNT1hX8gHvw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/117b7886-8c4d-45c9-912d-b2f2e59264bcn%40googlegroups.com.

Suzuki Tomohiro

unread,
Feb 16, 2021, 7:51:59 AM2/16/21
to Flutter Development (flutter-dev)

Would you explain which case your problem is?

You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/CAJxKiYJsEOhaLuJ863-0Li6r%2BED7Ya%3Dw59jiVXcbu9eX%3DQ%2B%3DNw%40mail.gmail.com.

Manish Vlog

unread,
Feb 18, 2021, 2:07:56 AM2/18/21
to Suzuki Tomohiro, Flutter Development (flutter-dev)
Reply all
Reply to author
Forward
0 new messages