flutter: how to make carousel slider like this? - flutter

Padding(
padding: const EdgeInsets.only(top: 00.0, bottom: 21),
child: CarouselSlider(
items: <Widget>[
for (var i = 0; i < sliderListData.length; i++)
InkWell(
onTap: () async {
print(i);
},
child: Container(
width: double.infinity,
child: Image.asset(
sliderListData[i]['image'],
fit: BoxFit.fitHeight)),
),
],
options: CarouselOptions(
aspectRatio: 16 / 5.8,
viewportFraction: 0.75,
padEnds: true,
initialPage: 0,
enableInfiniteScroll: true,
reverse: false,
autoPlay: false,
autoPlayInterval: Duration(seconds: 5),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
enlargeCenterPage: false,
scrollDirection: Axis.horizontal,
onPageChanged: (index, reason) {})),
)
I want to create slider like this
but its created like this

You can set enableInfiniteScroll: false,
options: CarouselOptions(
aspectRatio: 16 / 5.8,
viewportFraction: 0.75,
padEnds: true,
initialPage: 0,
enableInfiniteScroll: false,
reverse: false,
autoPlay: false,
autoPlayInterval: Duration(seconds: 5),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
enlargeCenterPage: false,
scrollDirection: Axis.horizontal,
onPageChanged: (index, reason) {})),
),

Related

dot indicator below the carousel slider moving along with other items - Flutter

I am using carousel slider package with smooth page indicator package to display the list of post items in Listview.builder.
I have successfully showing both the post and indicator in UI.
But my problem is while i swipe the images in first item, the dot indicator for all the items are moving along with it.
This is the code.
final CarouselController _controller = CarouselController();
CarouselSlider(
carouselController: _controller,
options: CarouselOptions(
height: 160.h,
enlargeCenterPage: false,
autoPlay: false,
aspectRatio: 16 / 9,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
},
autoPlayCurve: Curves.easeInBack,
enableInfiniteScroll:
dList[index].postUrl!.length == 1
? false
: true,
autoPlayAnimationDuration:
Duration(seconds: 10),
viewportFraction: 1.2,
),
items: name.map((item) {
return Padding(
padding: EdgeInsets.zero,
child: Container(
height: 200.h,
width: 350.w,
margin:
EdgeInsets.symmetric(vertical: 0),
child: InkWell(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext context) {
return Scaffold(
// backgroundColor: Colors.black,
extendBodyBehindAppBar: true,
appBar: AppBar(
backgroundColor:
Colors.transparent,
),
body: CarouselSlider(
carouselController:
_controller,
options: CarouselOptions(
height:
MediaQuery.of(context)
.size
.height,
enlargeCenterPage: true,
autoPlay: false,
aspectRatio: 16 / 9,
onPageChanged:
(index, reason) {
setState(() {
_current = index;
});
},
autoPlayCurve:
Curves.easeIn,
enableInfiniteScroll:
dList[index]
.postUrl!
.length ==
1
? false
: true,
viewportFraction: 1.0,
),
items: name.map((item) {
return Padding(
padding: EdgeInsets.zero,
child: Container(
height: MediaQuery.of(
context)
.size
.height,
width: MediaQuery.of(
context)
.size
.width,
margin: EdgeInsets
.symmetric(
vertical: 0),
child:
InteractiveViewer(
child: getRectangleImageForQRCode(
item.toString()),
),
),
);
}).toList(),
),
);
}));
},
child: getRectangleImageForQRCode(
item.toString()),
),
),
);
}).toList(),
),
dList[index].postUrl!.length == 1
? Container()
: Align(
alignment: Alignment.center,
child: AnimatedSmoothIndicator(
activeIndex: _current,
count:
dList[index].postUrl!.length <= 2
? 2
: 3,
effect: JumpingDotEffect(
dotHeight: 10.h,
dotWidth: 10.h,
jumpScale: .7,
verticalOffset: 20,
activeDotColor: Colors.red,
dotColor: Colors.grey),
),
)
What wrong in this code? Please help friends.

Flutter Carousel, put side items behind the center card

I want to know how to put the carousel items behind the center item, then when it slides there will be no spaces between items but it will stay behind
I have this:
And I want somethig like this:
This is my code:
CarouselSlider(
options: CarouselOptions(
height: Sizes.width,
enableInfiniteScroll: true,
aspectRatio: 2.0,
enlargeCenterPage: true,
viewportFraction: 0.8,
onPageChanged: (index, reason) =>
setState(() => currentCard = index),
),
items: hardcore.map((i) {
return Builder(builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 0),
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: Image.asset(i, fit: BoxFit.cover)));
});
}).toList()),

How to put Indicator no image flutter

how to put on image like the design. I was learn on youtube but tutorial have only outside, I try to use Carousel_Pro but it's can't use because it's not nullSafety .
Center(
child: CarouselSlider(
carouselController: _carouselController,
options: CarouselOptions(
initialPage: 0,
height: MediaQuery.of(context).size.height * 0.23,
viewportFraction: 1.0,
enlargeCenterPage: false,
onPageChanged: (index, reason) =>
setState(() => activeIndex = index)
// autoPlay: false,
),
items: imageList
.map((item) => Container(
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: SizedBox(
height:
MediaQuery.of(context).size.height *
1,
width:
MediaQuery.of(context).size.width * 1,
child: Image.network(
item,
fit: BoxFit.cover,
height:
MediaQuery.of(context).size.height *
1,
))),
))
.toList(),
)),
buildIndicator(),
Use the Stack widget : https://api.flutter.dev/flutter/widgets/Stack-class.html
It will help you to stack widget one on another instead of one under another
Center(
child: CarouselSlider(
carouselController: _carouselController,
options: CarouselOptions(
initialPage: 0,
height: MediaQuery.of(context).size.height * 0.23,
viewportFraction: 1.0,
enlargeCenterPage: false,
onPageChanged: (index, reason) =>
setState(() => activeIndex = index)
// autoPlay: false,
),
items: imageList
.map((item) => Container(
child: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: SizedBox(
height:
MediaQuery.of(context).size.height *
1,
width:
MediaQuery.of(context).size.width * 1,
child: Image.network(
item,
fit: BoxFit.cover,
height:
MediaQuery.of(context).size.height *
1,
))),
))
.toList(),
)),
imageList.lenght> 0? buildIndicator() : SizedBox(),

How to combine SingleChildScrollView and vertical carousel?

CarouselSlider(
options: CarouselOptions(
autoPlay: false,
enableInfiniteScroll: false,
height: MediaQuery.of(context).size.height,
enlargeCenterPage: false,
viewportFraction: 1,
initialPage: 0,
scrollDirection: Axis.vertical,
pageSnapping: false,
onPageChanged: (index, reason) {
setState(() {
_currentSlider = index;
});
}),
items: images.map((e) {
return Builder(
builder: (BuildContext context) {
return Center(
child: SingleChildScrollView(
child: Image.memory(
e,
fit: BoxFit.fitWidth,
),
),
);
},
);
}).toList(),
carouselController: _controller,
),
I combined SingleChildScrollView and CarouselSlider. But when I scroll down image, SingleChildScrollView intercept to move next image.
How can I solve this problem?

Flutter how to show 3 slider

Flutter i need to show slider image like this
I use Carouselslide butnot able to achieve same like as i show
my code is
Container(
width: double.infinity,
child: CarouselSlider(
options: CarouselOptions(
disableCenter: true,
enableInfiniteScroll: false,
viewportFraction: 0.7,
enlargeCenterPage: false,
height: Height * 0.21,
),
items: list
.map((item) => Container(
child: Image.asset(item),
))
.toList(),
)),
Its showing like this
I need to show as show in above image. Or is it not possible by Carousel slider ?
Try this code
Padding(
padding: EdgeInsets.only(left: 0, right: 0, top: 0),
child: Container(
child: CarouselSlider(
options: CarouselOptions(
height: Height * 0.21,
autoPlay: true,
viewportFraction: 1.0,
disableCenter: true,
enableInfiniteScroll: false,
),
items: list
.map((item) => Container(
child: Image.network(item, fit: BoxFit.cover, width: 400),
))
.toList(),
)),
)