Carousel animation flutter with photos - flutter

I want to do a carousel animation with photos that starts by itself and doesn't need to be touch to move the photos (slide)and the photos to go to the right . The app that i am working in it's flutter .

You can use carousel_slider flutter package to achieve this. You can refer to the GitHub for documentation.
In Short,
Add carousel_slider: ^2.2.1 to your pubspec.yaml
import 'package:carousel_slider/carousel_slider.dart';
Simply create a CarouselSlider widget, and pass the required params:
pass autoPlay option as true on CarouselOptions()
CarouselSlider(
options: CarouselOptions(
height: 400.0,
enableInfiniteScroll: true,
autoPlay: true
),
items: [1,2,3,4,5].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Colors.amber
),
child: Text('text $i', style: TextStyle(fontSize: 16.0),)
);
},
);
}).toList(),
)

Related

How can I apply to image both ink well ripple effect during pressing and shimmer effect during loading?

I would like an image with shimmer effect applied while loading, similar to the fancy_shimmer_image package, to also receive ripple effect from an InkWell. Is there a way to do this?
The only way i found to do that is this "trick". Use a Stack for set a widget on top of your image. And then the inkwell effect works:
Stack(
children: [
// image with shimmer effect
FancyShimmerImage(
imageUrl:
'https://cdn.pixabay.com/photo/2014/06/03/19/38/board-361516_960_720.jpg',
shimmerBaseColor: Colors.amberAccent,
shimmerHighlightColor: Colors.redAccent,
shimmerBackColor: Colors.greenAccent,
),
//use this widget on top to do the effect
Positioned.fill(
child: Material(
color: Colors.transparent,
child: InkWell(
// splashColor: Colors.lightGreenAccent,
onTap: () {
print("on tap");
},
),
),
),
],
),
use the shimmer package and cached network image
and use it like that
CachedNetworkImage(
imageUrl: prov
.cart
.cartItems[index]
.image,
placeholder:
(context, url) =>
Shimmer.fromColors(
baseColor: Colors.grey.shade300,
highlightColor: Colors.white,
enabled: true, child: Image.asset(
'assets/images/product_placeholder.png',
),
)
),

Using Flutter: Why does Rive render the first animation used over any subsequent animations when using Liquid_Swipe?

Given the basic example below, as you begin to swipe and reveal the next container, it's animation is shown correctly, but once the page is fully revealed the animation is replaced with the first container's animation (so the Smile will show up during reveal, but once fully revealed it is immediately replaced by the Ball), no matter the number of 'pages' the first 2 animations are the only two ever shown, and the first animation will ultimately be the one showing once a page is fully revealed - what am I failing to account for? - please and thank you.
rive: ^0.8.4
liquid_swipe: ^2.1.1
class _MyHomePageState extends State<MyHomePage> {
final pages = [
Container(
color: Colors.purple,
child: Center(
child: RiveAnimation.asset(
"assets/Ball.riv",
controllers: [SimpleAnimation('Ball', autoplay: true)],
artboard: 'Ball',
animations: const ['Ball'],
fit: BoxFit.scaleDown,
),
),
),
Container(
color: Colors.orange,
child: Center(
child: RiveAnimation.asset(
"assets/Smile.riv",
controllers: [SimpleAnimation('Smile', autoplay: true)],
artboard: 'Smile',
animations: const ['Smile'],
fit: BoxFit.scaleDown,
),
),
),
];
#override
Widget build(BuildContext context) => Scaffold(
body: LiquidSwipe(
enableSideReveal: true,
waveType: WaveType.liquidReveal,
slideIconWidget: const Icon(Icons.arrow_back_rounded, color: Colors.white),
pages: pages,
),
);
}
so obviously I am new to Flutter...
Solution:
SizedBox( key: UniqueKey(),
🤦
moving around stateful widgets - I needed unique keys

make photo bigger when click on flutter

how to make the picture zoomable when the photo is clicked, here's the code I made to display the image
Column(
children: [
image11 != null
? Image.file(
image11,
width: 50,
height: 50,
fit: BoxFit.cover,
)
: Text(" Bagian Belakang"),
Container(
margin: const EdgeInsets.fromLTRB(14, 5, 0, 0),
child: RaisedButton(
padding: EdgeInsets.all(10),
onPressed: () {
pickImage11(ImageSource.camera);
},
child: Icon(Icons.camera),
),
),
],
),
Taking inspiration from this answer Hero animation with an AlertDialog
You can use a Hero widget combined with a PageRouteBuilder to imitate a zoom feature:
Navigator.of(context).push(
PageRouteBuilder(
opaque: false,
barrierDismissible:true,
pageBuilder: (BuildContext context, _, __) {
return Hero(
tag: "zoom",
child: Image.file(...),
);
}
)
);
EDIT: I found barrier dismissable not working and found the solution here: Flutter SizeTransition and PageRouteBuilder not working
You will have to wrap the Hero widget with a defined width and height to get the optimum zoom level.

Flutter Carousel no Image and some other difficulties

I am new to flutter as well as app dev.
I was trying to implement a STAEFUL carousel that responds and redirects to a certain link when an image in the carousel is clicked.
Here are the problems I faced.
I am not getting how to make the carousel images stateful should I implement a Gesture detector or Inkwell?
Should Every image has to be tagged within the [LIST] or the entire carousel can be tagged with a single inkwell or gesture detector?
Please have a look in the code, is it possible to map the redirect addresses as a list! (This will be much easier to add images, but what is bothering me here is, do I have to recompile and upload the app to AppStore each time I add new image address and respective redirect link?)
Most importantly the carousel isn't showing the images only the URL
what do these mean in this part of the code?
[LIST].map((i) {}
and
'text $i'
items: [imgList].map((i) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(color: Colors.blueAccent),
child: Text('text $i', style: TextStyle(fontSize: 16.0),)
);
here is the entire code
import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
//import 'package:carousel_slider/carousel_controller.dart';
import 'package:carousel_slider/carousel_options.dart';
List<String> imgList =
[
'https://static.scientificamerican.com/sciam/cache/file/92E141F8-36E4-4331-BB2EE42AC8674DD3_source.jpg',
'https://icatcare.org/app/uploads/2018/07/Thinking-of-getting-a-cat.png',
];
List<String> redirectList =
[
'img 1 redirect link',
'img 2 redirect link',
]; //yet to be configured
class VerticalSliderDemo extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
child: CarouselSlider(
options: CarouselOptions(
aspectRatio: 2.0,
enlargeCenterPage: true,
scrollDirection: Axis.horizontal,
autoPlay: true,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
),
items: [imgList].map((i) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(color: Colors.blueAccent),
child: Text('text $i', style: TextStyle(fontSize: 16.0),)
);
}
).toList(),
),
);
}
}
https://github.com/Amit506/courouselexample
in this link i have uploaded correct working courousel slider .
if you want to know the differenve between text widget and image widget you should refer to official documentation of flutter they have written all the information of widgets.
https://api.flutter.dev/flutter/widgets/Image-class.html
https://github.com/Amit506/dart-foods/blob/main/lib/TabBars.dart/TabBar1.dart
in this link i have used courousel builder in one of my project you can refer to it for advance courousel slider.
To make image responsive to tap you only have to wrap image widget with gesturedetector /inkwell or any other widgets available In this case you can wrap image.Network
You can't show picture in text widget.for showing image from url you have to use Image.Network () instead of text widget. text widget is used to show only text .
to show any network image you can do
Image.Network('url'). If u want i can can show you code

How to Navigate to other Screen using Carousel

I wanted to have a carousel with 5 photos and when I press any of the images I want to navigate to a different screen. I watched many videos but couldn't find any solutions. I used carousel_slider package.
CarouselSlider(
CarouselOptions(height: 400.0),
items: [1,2,3,4,5].map((i) {
return Builder(
builder: (BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Colors.amber
),
child: Text('text $i', style: TextStyle(fontSize: 16.0),)
);
},
);
}).toList(),
)
Imagine I have 5 different pages and when I press any of the pictures in the carousel then I should be navigated to a particular page. If I use a Gesture detector how can I navigate him using navigator.push?
Try using ManuallyControlledSlider from
https://github.com/serenader2014/flutter_carousel_slider/blob/master/example/lib/main.dart but change onPressed callback inside
Iterable -> RaisedButton to navigate on specific page.