'Incorrect use of ParentDataWidget for CarouselSlider
I have used CarouselSlider for my other projects but first time I could not find the reason why it gives that warning. Here is a simplified of code part. I did not use any flexivle or expanded widget in Stack or its parent. Mostly answers about that but there has to be a point that I am missing . Here is the link of dependency. Do you have any suggestions?
return Scaffold(
body: Column(
children: [
SizedBox(
height: (MediaQuery.of(context).size.height -
70.h -
MediaQuery.of(context).viewPadding.top) *
0.35,
child: slider()),
])
);
Stack slider() {
return Stack(
children: [
CarouselSlider(
options: CarouselOptions(
autoPlayInterval: const Duration(seconds: 2),
autoPlay: true,
// aspectRatio: 2.3,
height: (MediaQuery.of(context).size.height -
70.h -
MediaQuery.of(context).viewPadding.top) *
0.35,
viewportFraction: 0.8,
enlargeCenterPage: true,
enlargeStrategy: CenterPageEnlargeStrategy.scale,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
}),
items: images
.map(
(item) => Center(child: item),
)
.toList(),
),
Positioned(
child: Column(
children: [
SizedBox(
height: (MediaQuery.of(context).size.height -
70.h -
MediaQuery.of(context).viewPadding.top) *
0.3),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: images.asMap().entries.map((entry) {
return Container(
width: 8.w,
height: 8.h,
margin:
EdgeInsets.symmetric(vertical: 8.w, horizontal: 4.h),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: ColorSelect.color
.withOpacity(_current == entry.key ? 1 : 0.4)),
);
}).toList(),
),
],
),
)
],
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
