From 0ee75bcff070db91c46bafc3babca8c17e074b8b Mon Sep 17 00:00:00 2001 From: Chloe Date: Tue, 12 May 2020 22:47:33 +0200 Subject: [PATCH] feat: add scaleForDoubleTap to set the desire scale. --- lib/src/zoomable/zoomable_widget.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/src/zoomable/zoomable_widget.dart b/lib/src/zoomable/zoomable_widget.dart index 3ab4895..0d36c31 100644 --- a/lib/src/zoomable/zoomable_widget.dart +++ b/lib/src/zoomable/zoomable_widget.dart @@ -5,8 +5,10 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_advanced_networkimage/src/utils.dart'; class ZoomableWidget extends StatefulWidget { + ZoomableWidget({ Key key, + this.scaleForDoubleTap: 1.0, this.minScale: 0.7, this.maxScale: 1.4, this.initialScale: 1.0, @@ -27,7 +29,8 @@ class ZoomableWidget extends StatefulWidget { this.onZoomChanged, this.resetDuration: const Duration(milliseconds: 250), this.resetCurve: Curves.easeInOut, - }) : assert(minScale != null), + }) : assert(scaleForDoubleTap != null), + assert(minScale != null), assert(maxScale != null), assert(initialScale != null), assert(initialOffset != null), @@ -43,6 +46,9 @@ class ZoomableWidget extends StatefulWidget { assert(enableFling != null), assert(flingFactor != null); + /// The scale size for double tap + final double scaleForDoubleTap; + /// The minimum size for scaling. final double minScale; @@ -244,10 +250,10 @@ class _ZoomableWidgetState extends State { _curve = widget.resetCurve; if (widget.zoomSteps > 0) - _stepLength = (widget.maxScale - 1.0) / widget.zoomSteps; + _stepLength = (widget.scaleForDoubleTap - 1.0) / widget.zoomSteps; double _tmpZoom = _zoom + _stepLength; - if (_tmpZoom > widget.maxScale || _stepLength == 0.0) _tmpZoom = 1.0; + if (_tmpZoom > widget.scaleForDoubleTap || _stepLength == 0.0) _tmpZoom = 1.0; setState(() { _zoom = _tmpZoom;