I am using flutter_swiper
to swipe images from a list a images. I want to use MatrixGestureDetector
to move swiper containing images and perform zoom-in zoom-out to it. When i set the swiper layout to Default it works perfectly but when i change it to Custom or any other layout it stops working. Can anyone tell me what should be the problem???
Here is my code
Stack(
children: <Widget>[
/// EYES
new Align(
child: MatrixGestureDetector(
onMatrixUpdate: (m, tm, sm, rm) {
setState(() {
notifier1.value =m;
});
},
shouldRotate: false,
// shouldScale: true,
// shouldTranslate: false,
child: AnimatedBuilder(
animation: notifier1,
builder: (ctx, child) {
return Transform(
transform: notifier1.value,
child: Stack(
children: <Widget>[
Align(
alignment: Alignment(0, -0.1),
child: Tooltip(
message: "Eyes Selected",
child: Container(
width: ew,
height: eh,
//color: Colors.purple,
child: new SizedBox(
child: Swiper(
onTap: (index){
itemNo = 1;
}
,
itemBuilder:
(BuildContext context,
int index) {
return Image.asset(
eImage[index],
);
},
itemCount: eImage.length,
itemWidth: 300,
itemHeight: 600,
//control: new SwiperControl(),
layout: SwiperLayout.DEFAULT,
customLayoutOption:
CustomLayoutOption(
startIndex: -1,
stateCount: 3)
.addRotate([
0 / 180,
0.0,
0 / 180
]).addTranslate([
Offset(-400.0, 0.0),
Offset(0.0, 0.0),
Offset(370, -40.0),
]),
),
height: 200,
width: 350,
),
),
),
),
],
),
);
},
),
),
),
],
),
I got the solution. i was using custom layout just to give starting index dynamic but i later found that i can do it in default layout too. Swiper custom layout is buggy so i have raised the problem in git repository.
Solution:-
Use a variable for index:
var pos=0
//any index u wantAfter that pass same index in swiper item builder and update it in runtime