Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Image that Clicked on Previous Page First #211

Open
slimmziy opened this issue Jun 27, 2020 · 0 comments
Open

Show Image that Clicked on Previous Page First #211

slimmziy opened this issue Jun 27, 2020 · 0 comments

Comments

@slimmziy
Copy link

slimmziy commented Jun 27, 2020

Hello, so I'm trying on how to show the picture on the swiper to be the first picture that I clicked on the previous page, anyone?

This is the swiper Code as i reference from here

`import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class ImageSwiper extends StatefulWidget {
@OverRide
_ImageSwiperState createState() => _ImageSwiperState();
}

class _ImageSwiperState extends State {

final List imgList = [
'assets/images/gallery/Image1.jpg',
'assets/images/gallery/Image2.jpg',
'assets/images/gallery/Image3.jpg',
'assets/images/gallery/Image4.jpg',
'assets/images/gallery/Image5.png',
'assets/images/gallery/Image6.jpg',
'assets/images/gallery/Image7.jpg',
'assets/images/gallery/Image8.jpg'
];

@OverRide
Widget build(BuildContext context) {
return Scaffold( backgroundColor: Colors.orange,
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.white10,
elevation: 0,
leading: Container(
padding: EdgeInsets.fromLTRB(20, 20, 0, 0),
child: InkWell(
child: Image.asset(
'assets/images/wp_back_button_icon.png',
height: 250,
),
onTap: () {
Navigator.pop(context);
},
),
),
),
body: Container(
child: Swiper(
viewportFraction: 0.8,
scale: 0.9,
autoplay: false,
itemCount: imgList.length,
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () {
switch (index) {
case 0:
print('Image 1');
break;
case 0:
print('Image 2');
break;
case 1:
print('Image 3');
break;
case 2:
print('Image 4');
break;
case 3:
print('Image 5');
break;
case 4:
print('Image 6');
break;
case 4:
print('Image 7');
break;
case 4:
print('Image 8');
break;
}
},
child: Image.asset(
imgList[index],
fit: BoxFit.fitWidth,
),
);
},
pagination: SwiperPagination(),
),
),
);
}
}`

Case is:

  1. Open app, see many images
  2. Click on specific image (example, Sunset.jpg)
  3. App route me to the swiper page (in this part i want the first image appear on the swiper is the one i clicked (Sunset.jpg))

Many thanks,
SLim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant