Skip to content

Show Image that Clicked on Previous Page First #211

Open
@slimmziy

Description

@slimmziy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions