Skip to content

Commit cd92a11

Browse files
committed
gf slider split view port problem fixing
1 parent 505cd6f commit cd92a11

3 files changed

Lines changed: 32 additions & 28 deletions

File tree

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class _MyHomePageState extends State<MyHomePage> {
105105
passiveIndicator: Colors.pink.withOpacity(0.4),
106106
viewportFraction: 1.0,
107107
aspectRatio: 2.0,
108-
// autoPlay: true,
108+
autoPlay: true,
109109
enlargeMainPage: true,
110110
pagination: true,
111111
items: imageList.map(

lib/components/slider/carousel.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ class _CarouselState extends State<Carousel> with TickerProviderStateMixin {
190190
@override
191191
Widget build(BuildContext context) {
192192
return GestureDetector(
193-
onHorizontalDragStart: this.onDragStart,
194-
onHorizontalDragUpdate: this.onDrag,
195-
onHorizontalDragEnd: this.onDragEnd,
193+
// onHorizontalDragStart: this.onDragStart,
194+
// onHorizontalDragUpdate: this.onDrag,
195+
// onHorizontalDragEnd: this.onDragEnd,
196196
child: Container(
197197
width: double.infinity,
198198
height: this.size,

lib/components/slider/gf_slider.dart

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
233233

234234
int _current = 0;
235235

236+
236237
@override
237238
Widget build(BuildContext context) {
239+
238240
return Stack(
239241
children: <Widget>[
240242
getPageWrapper(PageView.builder(
@@ -258,7 +260,27 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
258260

259261
return AnimatedBuilder(
260262
animation: widget.pageController,
261-
child: widget.items[index],
263+
// child: widget.items[index],
264+
child: Container(
265+
width: double.infinity,
266+
height: this.size,
267+
child: Stack(
268+
children: [
269+
Positioned(
270+
left: 0,
271+
child: Row(
272+
children: widget.items.map((child) {
273+
return Container(
274+
width: this.size,
275+
height: this.size,
276+
child: child,
277+
);
278+
}).toList(),
279+
),
280+
),
281+
]
282+
),
283+
),
262284
builder: (BuildContext context, child) {
263285
// on the first render, the pageController.page is null,
264286
// this is a dirty hack
@@ -281,35 +303,17 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
281303

282304
if (widget.scrollDirection == Axis.horizontal) {
283305
return Center(
284-
// child: SizedBox(
285-
// height: distortionValue * height, child: child),
286-
child: Container(
287-
width: double.infinity,
288-
height: this.size,
289-
child: Stack(
290-
children: [
291-
Positioned(
292-
left: 0,
293-
child: Row(
294-
children: widget.items.map((child) {
295-
return Container(
296-
width: this.size,
297-
height: this.size,
298-
child: child,
299-
);
300-
}).toList(),
301-
),
302-
),
303-
]
304-
),
305-
),
306+
child: SizedBox(
307+
height: distortionValue * height, child: child),
308+
306309
);
307310
} else {
308311
return Center(
309312
child: SizedBox(
310313
width: distortionValue *
311314
MediaQuery.of(context).size.width,
312-
child: child));
315+
child: child),
316+
);
313317
}
314318
},
315319
);

0 commit comments

Comments
 (0)