From 8e8f2953cd23f55532ae61752fe23b77e5f1d458 Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Mon, 3 Jun 2024 20:53:43 -0600 Subject: [PATCH 1/6] Add flutter_lints as a dev dependency --- pubspec.lock | 83 +++++++++++++++++++++++++++++++++++++++------------- pubspec.yaml | 1 + 2 files changed, 63 insertions(+), 21 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index a0798dc..6f0b067 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" fake_async: dependency: transitive description: @@ -54,43 +54,83 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" + url: "https://pub.dev" + source: hosted + version: "4.0.0" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" + url: "https://pub.dev" + source: hosted + version: "4.0.0" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" sky_engine: dependency: transitive description: flutter @@ -108,18 +148,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -140,10 +180,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" vector_math: dependency: transitive description: @@ -152,13 +192,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "14.2.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/pubspec.yaml b/pubspec.yaml index 8b468d0..7f1d584 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: repository: https://github.com/tkortekaas/pinch_zoom From 2fd0aac8a9c8fc75900b3ad078e2b0ca46bc2bef Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Mon, 3 Jun 2024 20:54:54 -0600 Subject: [PATCH 2/6] Add analysis_options.yaml --- analysis_options.yaml | 1 + 1 file changed, 1 insertion(+) create mode 100644 analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..f9b3034 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml From ae76a6f35c615c9704e80679b82fe0dcf60563cb Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Mon, 3 Jun 2024 20:57:05 -0600 Subject: [PATCH 3/6] Address the analysis_options linter complaints * Make PinchZoom constructor const * Add super.key parameter to PinchZoom constructor * Don't expose private _PinchZoomState in public API PinchZoom * Make child the last argument passes into InteractiveViewer * Make _endScrollTimer use a const Duration --- lib/src/pinch_zoom_widget.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/pinch_zoom_widget.dart b/lib/src/pinch_zoom_widget.dart index f06f551..8347657 100644 --- a/lib/src/pinch_zoom_widget.dart +++ b/lib/src/pinch_zoom_widget.dart @@ -25,8 +25,9 @@ class PinchZoom extends StatefulWidget { /// /// * [onZoomEnd] called when the widget is back to its idle state. - PinchZoom( - {required this.child, + const PinchZoom( + {super.key, + required this.child, // This default maxScale value is eyeballed as reasonable limit for common // use cases. this.maxScale = 3.0, @@ -35,7 +36,7 @@ class PinchZoom extends StatefulWidget { this.onZoomEnd}); @override - _PinchZoomState createState() => _PinchZoomState(); + State createState() => _PinchZoomState(); } class _PinchZoomState extends State @@ -52,7 +53,6 @@ class _PinchZoomState extends State Widget build(BuildContext context) { return InteractiveViewer( key: widgetKey, - child: widget.child, scaleEnabled: widget.zoomEnabled, panEnabled: widget.zoomEnabled, maxScale: widget.maxScale, @@ -78,13 +78,14 @@ class _PinchZoomState extends State endHandled = false; _transformationController.value = identity; } else { - _endScrollTimer = Timer(Duration(milliseconds: 100), () { + _endScrollTimer = Timer(const Duration(milliseconds: 100), () { endHandled = false; _transformationController.value = identity; }); } }, transformationController: _transformationController, + child: widget.child, ); } From 6391697842b822f5f0c7b07c65786a10f487905d Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Mon, 3 Jun 2024 20:58:49 -0600 Subject: [PATCH 4/6] Update example pubspec --- example/pubspec.lock | 69 ++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index c32afd6..5c75b5d 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -37,10 +37,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" fake_async: dependency: transitive description: @@ -59,45 +59,69 @@ packages: description: flutter source: sdk version: "0.0.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" matcher: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.12.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" pinch_zoom: dependency: "direct main" description: path: ".." relative: true source: path - version: "1.0.0" + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -115,18 +139,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -147,10 +171,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.7.0" vector_math: dependency: transitive description: @@ -159,13 +183,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - web: + vm_service: dependency: transitive description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "14.2.1" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" From 73826863d2c8f3e512cd12324c867bb2f41943ce Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Tue, 4 Jun 2024 20:46:07 -0600 Subject: [PATCH 5/6] Add missing dispose method --- lib/src/pinch_zoom_widget.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/pinch_zoom_widget.dart b/lib/src/pinch_zoom_widget.dart index 8347657..ea48726 100644 --- a/lib/src/pinch_zoom_widget.dart +++ b/lib/src/pinch_zoom_widget.dart @@ -141,4 +141,12 @@ class _PinchZoomState extends State }, ); } + + @override + void dispose() { + _transformationController.dispose(); + _overlayEntry?.dispose(); + _endScrollTimer?.cancel(); + super.dispose(); + } } From 253d64adf0941367572e224079035f8e16c55d0e Mon Sep 17 00:00:00 2001 From: zmuranaka Date: Tue, 4 Jun 2024 20:48:34 -0600 Subject: [PATCH 6/6] Remove [resetDuration] from doc comment * Also change 'an PinchZoom' to 'a PinchZoom' --- lib/src/pinch_zoom_widget.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/src/pinch_zoom_widget.dart b/lib/src/pinch_zoom_widget.dart index ea48726..3642d11 100644 --- a/lib/src/pinch_zoom_widget.dart +++ b/lib/src/pinch_zoom_widget.dart @@ -8,7 +8,7 @@ class PinchZoom extends StatefulWidget { final bool zoomEnabled; final Function? onZoomStart, onZoomEnd; - /// Create an PinchZoom. + /// Create a PinchZoom. /// /// * [child] is the widget used for zooming. /// This parameter must not be null. @@ -17,8 +17,6 @@ class PinchZoom extends StatefulWidget { /// Defaults to 3.0. /// Cannot be null, and must be greater than zero. /// - /// * [resetDuration] is the length of time this animation should last. - /// /// * [zoomEnabled] can be used to enable/disable zooming. /// /// * [onZoomStart] called when the widget goes to its zoomed state.