Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert breaking constructor change introduced in 1.3.0 #45

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# EasyImageViewer Changelog

## 1.3.1

- Revert breaking constructor change introduced in 1.3.0. This changes the default `EasyImageView` constructor back to accepting an `ImageProvider` instead of a `Widget`. Constructing an `EasyImageView` with a widget can be done by using a new named constructor: `EasyImageView.imageWidget`.

## 1.3.0

- Update Flutter to `3.16.3`
Expand Down
8 changes: 7 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ class _MyHomePageState extends State<MyHomePage> {
);
showImageViewerPager(context, customImageProvider);
}),
SizedBox( // Tiny image just to test the EasyImageView constructor
width: MediaQuery.of(context).size.width,
height: 56,
child: EasyImageView(
imageProvider: Image.network("https://picsum.photos/id/1001/4912/3264").image)
),
SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 2.0,
height: MediaQuery.of(context).size.height / 2.4,
child: EasyImageViewPager(
easyImageProvider: _easyEmbeddedImageProvider,
pageController: _pageController),
Expand Down
21 changes: 11 additions & 10 deletions lib/src/easy_image_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class EasyImageView extends StatefulWidget {
final void Function(double)? onScaleChanged;

/// Create a new instance that accepts an [ImageProvider]
EasyImageView.provider(ImageProvider imageProvider,
{Key? key,
double minScale = 1.0,
double maxScale = 5.0,
bool doubleTapZoomable = false,
void Function(double)? onScaleChanged})
: this(
EasyImageView({
Key? key,
required ImageProvider imageProvider,
double minScale = 1.0,
double maxScale = 5.0,
bool doubleTapZoomable = false,
void Function(double)? onScaleChanged,
}) : this.imageWidget(
Image(image: imageProvider),
key: key,
imageWidget: Image(image: imageProvider),
minScale: minScale,
maxScale: maxScale,
doubleTapZoomable: doubleTapZoomable,
Expand All @@ -36,9 +37,9 @@ class EasyImageView extends StatefulWidget {

/// Create a new instance
/// The optional [doubleTapZoomable] boolean defaults to false and allows double tap to zoom.
const EasyImageView({
const EasyImageView.imageWidget(
this.imageWidget, {
Key? key,
required this.imageWidget,
this.minScale = 1.0,
this.maxScale = 5.0,
this.doubleTapZoomable = false,
Expand Down
5 changes: 2 additions & 3 deletions lib/src/easy_image_view_pager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ class _EasyImageViewPagerState extends State<EasyImageViewPager> {
controller: widget.pageController,
scrollBehavior: MouseEnabledScrollBehavior(),
itemBuilder: (context, index) {
return EasyImageView(
return EasyImageView.imageWidget(
widget.easyImageProvider.imageWidgetBuilder(context, index),
key: Key('easy_image_view_$index'),
imageWidget:
widget.easyImageProvider.imageWidgetBuilder(context, index),
doubleTapZoomable: widget.doubleTapZoomable,
onScaleChanged: (scale) {
if (widget.onScaleChanged != null) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: easy_image_viewer
description: An easy image viewer with pinch & zoom, multi image, and built-in full-screen dialog support.
version: 1.3.0
version: 1.3.1
homepage: https://github.com/thesmythgroup/easy_image_viewer

environment:
Expand Down
18 changes: 9 additions & 9 deletions test/easy_image_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void main() {

Widget testWidget = MediaQuery(
data: const MediaQueryData(size: Size(600, 800)),
child: EasyImageView.provider(
imageProvider!, minScale: 0.5, maxScale: 6.0));
child: EasyImageView(
imageProvider: imageProvider!, minScale: 0.5, maxScale: 6.0));

await tester.pumpWidget(testWidget);

Expand Down Expand Up @@ -61,8 +61,8 @@ void main() {

Widget testWidget = MediaQuery(
data: const MediaQueryData(size: Size(600, 800)),
child: EasyImageView.provider(
imageProvider!,
child: EasyImageView(
imageProvider: imageProvider!,
minScale: 0.5,
maxScale: 6.0,
onScaleChanged: (scale) {
Expand Down Expand Up @@ -110,8 +110,8 @@ void main() {

Widget testWidget = MediaQuery(
data: const MediaQueryData(size: Size(600, 800)),
child: EasyImageView.provider(
imageProvider!,
child: EasyImageView(
imageProvider: imageProvider!,
minScale: 0.5,
maxScale: 6.0,
doubleTapZoomable: true,
Expand Down Expand Up @@ -163,8 +163,8 @@ void main() {

Widget testWidget = MediaQuery(
data: const MediaQueryData(size: Size(600, 800)),
child: EasyImageView.provider(
imageProvider!,
child: EasyImageView(
imageProvider: imageProvider!,
minScale: 0.5,
maxScale: 6.0,
doubleTapZoomable: true,
Expand Down Expand Up @@ -214,7 +214,7 @@ void main() {
data: const MediaQueryData(size: Size(600, 800)),
child: Directionality(
textDirection: TextDirection.ltr,
child: EasyImageView(imageWidget: provider.imageWidgetBuilder(context, 0))));
child: EasyImageView.imageWidget(provider.imageWidgetBuilder(context, 0))));

await tester.pumpWidget(testWidget);

Expand Down
Loading