flutter_advanced_networkimage 0.5.0

Flutter Advanced Network Image Provider #

Pub Package Pre Pub Package Build Status Coverage Status Donate

An advanced image provider provides caching and retrying for flutter app. Now with zoomable widget and transition to image widget.

Getting Started #

Installation #

Add this to your pubspec.yaml (or create it):

dependencies:
  flutter_advanced_networkimage: any

Then run the flutter tooling:

flutter packages get

Example #

// using image provider
Image(
  image: AdvancedNetworkImage(
    url,
    header: header,
    useDiskCache: true,
    cacheRule: CacheRule(maxAge: const Duration(days: 7)),
  ),
  fit: BoxFit.cover,
)
// work with precacheImage
precacheImage(
  AdvancedNetworkImage(
    url,
    header: header,
    useDiskCache: true,
    cacheRule: CacheRule(maxAge: const Duration(days: 7)),
  ),
  context,
);

// or svg provider (flutter_svg)
SvgPicture(
  AdvancedNetworkSvg(url, SvgPicture.svgByteDecoder, useDiskCache: true),
)
// get the disk cache folder size
int cacheSize = await DiskCache().cacheSize();
// clean the disk cache
bool isSucceed = await DiskCache().clear();
// using zooming widget & transitiontoimage widget
ZoomableWidget(
  minScale: 0.3,
  maxScale: 2.0,
  // default factor is 1.0, use 0.0 to disable boundary
  panLimit: 0.8,
  child: Container(
    child: TransitionToImage(
      AdvancedNetworkImage(url, timeoutDuration: Duration(minutes: 1)),
      // This is the default placeholder widget at loading status,
      // you can write your own widget with CustomPainter.
      placeholder: CircularProgressIndicator(),
      // This is default duration
      duration: Duration(milliseconds: 300),
    ),
  ),
)
// Reload feature included
TransitionToImage(
  image: AdvancedNetworkImage(url,
    loadedCallback: () {
      print('It works!');
    },
    loadFailedCallback: () {
      print('Oh, no!');
    },
    loadingProgress: (double progress) {
      print('Now Loading: $progress');
    },
  ),
  loadingWidgetBuilder: (double progress) => Text(progress.toString()),
  fit: BoxFit.contain,
  placeholder: const Icon(Icons.refresh),
  width: 400.0,
  height: 300.0,
  enableRefresh: true,
);
// Scale the widget size. (Origin point was fixed to screen's center)
ZoomableWidget(
  panLimit: 1.0,
  maxScale: 2.0,
  minScale: 0.5,
  singleFingerPan: true,
  multiFingersPan: false,
  enableRotate: true,
  child: Image(
    image: AssetImage('graphics/background.png'),
  ),
  zoomSteps: 3,
),

Details in example/ folder.

demo gif

If you have any problem or question, feel free to file issues.

Changelog #

[0.5.0]

  • Update dependency.
  • Use new flutter api.

[0.5.0-alpha.3]

  • Update flutter_svg.

[0.5.0-alpha.2]

  • Update provider.

[0.5.0-alpha.1]

  • Update folders.

[0.4.15]

  • TransitionToImage: Adding color property for use with BlendMode.
  • Initial data in keepCacheHealth.

[0.4.14]

  • Update flutter_svg to 0.12.0.
  • Exclude header in Object.== and Object.hashcode.

[0.4.13]

  • AdvancedNetworkImage: Replace the future with callback to avoid recall in getRealUrl.
  • AdvancedNetworkSvg: Replace the future with callback to avoid recall in getRealUrl.

[0.4.12]

  • ZoomableWidget: rewrite boundary.
  • zoomable_list: childKey is now deprecated.

[0.4.11]

  • AdvancedNetworkSvg: adapt flutter_svg 0.10.4.

[0.4.10]

  • AdvancedNetworkImage: fix missing content-length problem.

[0.4.9]

  • AdvancedNetworkImage: fix gzip download problem.

[0.4.8]

  • AdvancedNetworkImage: add preProcessing & postProcessing.

[0.4.7]

  • AdvancedNetworkImage: add disableMemoryCache.
  • TransitionToImage: add disableMemoryCacheIfFailed.
  • ZoomableWidget & ZoomableList: add a non-physical fling in enableFling & flingFactor.

[0.4.6]

  • TransitionToImage: add forceRebuildWidget.
  • AdvancedNetworkImage & AdvancedNetworkSvg: add fallbackAssetImage.

[0.4.5]

  • Update path_provider dependency.
  • Add download test and update download error function.

[0.4.4]

  • TransitionToImage: add disableMemoryCache;
  • TransitionToImage: add loadedCallback & loadFailedCallback.

[0.4.3]

  • AdvancedNetworkImage: fix download error.

[0.4.2]

  • AdvancedNetworkImage: download method fallback.

[0.4.1]

  • Fix TransitionToImage loadingWidget & placeholder padding problem.
  • Remove loadingWidget deprecated status.

[0.4.0]

  • flutter_advanced_networkimage: add cacheRule, loadingProgress and getRealUrl.
  • flutter_advanced_networksvg:: new in 0.4.0.
  • transition_to_image: match Image widget option(breaking change), loadingWidget is deprecated, use loadingWidgetBuilder(display progress), add borderRadius, fix setState() called after dispose().
  • disk_cache: new in 0.4.0.
  • zoomable_widget: add enableRotate.

[0.3.13]

  • Add autoCenter in zoomable_widget.
  • Check the widget mount state TransitionToImage.

[0.3.12]

  • Add onZoomStateChanged callback in zoomable_widget.

[0.3.11]

  • Fix TransitionToImage BoxFit again.

[0.3.10]

  • Improve zoomable_widget's bounce animation.
  • Fix the placeholder stretched issue.

[0.3.9]

  • Update http dependency.
  • Catch the bad images from remote.

[0.3.8]

  • Check if _imageInfo is null.

[0.3.7]

  • Give the cache file path.
  • Fix TransitionToImage BoxFit behavior.
  • Better impl on retry feature.
  • Remove quiver dependency.

[0.3.6]

  • Add fallbackImage in AdvancedNetworkImage.
  • Fix bug on retryLimit.
  • Tweek the GestureDetector in TransitionToImage.

[0.3.5]

  • Add a flag to disable interior GestureDetector in TransitionToImage.
  • Fix bug on printing error.

[0.3.4]

  • Add callback on AdvancedNetworkImage.
  • Add a bounce back boundary.
  • Add double tap step zoom.

[0.3.3]

  • Move the ZoomableWidget's origin point to screen's center.

[0.3.2]

  • Add multiFingersPan and remove enablePan.

[0.3.1]

  • Now allow ZoomableWidget to pan with single finger.

[0.3.0+1]

  • Update README.md.

[0.3.0]

  • Add ZoomableList.

[0.2.11]

  • Update placeholder in TransitionToImage.

[0.2.10]

  • Add image fit option to TransitionToImage.

[0.2.9+1]

  • Change dependencies version.

[0.2.9]

  • Fix ConcurrentModificationError again.

[0.2.8]

  • ZoomableWidget support boundary for now.

[0.2.7]

  • Drop support for ETag checking.

[0.2.6]

  • Fix an issue that causes a ConcurrentModificationError.

[0.2.5]

  • Move the cache files from app folder to temporary folder.

[0.2.4]

  • Add reloadWidget and fallbackWidget to TransitionToImage widget.

[0.2.3]

  • Add a minimum png to avoid some issues.
  • Add a reload button to TransitionToImage widget to reload the image if fetching network image failed.

[0.2.2+1]

  • Update some dependencies.

[0.2.2]

  • Adapt to dart 2 preview.

[0.2.1]

  • Support fallback image after retrying failed.

[0.2.0+1]

  • Cleanup example code.

[0.2.0]

  • Add timeoutDuration parameter, make some tweaks and add some doc comments to AdvancedNetworkImage imageprovider.

  • Make some tweaks for TransitionToImage widget.

  • Fix the panning issue which would shift when the scale is not 1.0 for ZoomableWidget.

[0.1.10]

  • Catch exception for file not found.

[0.1.9]

  • Add default blendmode to TransitionToImage widget.

[0.1.8]

  • Fix the listener leak problem for the TransitionToImage widget.

[0.1.7]

  • Add a TransitionToImage Widget, optimize ZoomableWidget and update example.

[0.1.6+2]

  • Downgrade http version.

[0.1.6+1]

  • Upgrade the dart SDK version.

[0.1.6]

  • Add animation to ZoomableWidget.

[0.1.5]

  • Update ZoomableWidget.

[0.1.4]

  • Update example.

[0.1.3]

  • Fix dependencies with http package.

[0.1.2]

  • Upgrade some dependencies version.

[0.1.1]

  • Downgrade some packages version.

[0.1.0]

  • An advanced image provider and a widget with zooming and panning.

example/README.md

flutter_advanced_networkimage_example #

Demonstrates how to use the flutter_advanced_networkimage plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_advanced_networkimage: ^0.5.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_advanced_networkimage/provider.dart';
import 'package:flutter_advanced_networkimage/transition.dart';
import 'package:flutter_advanced_networkimage/zoomable.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
97
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
98
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_svg ^0.13.0 0.13.1
http ^0.12.0 0.12.0+2
path ^1.6.0 1.6.2
path_provider ^1.1.0 1.1.2
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http_parser 3.1.3
meta 1.1.6 1.1.7
path_drawing 0.4.1
path_parsing 0.1.4
pedantic 1.8.0+1
petitparser 2.4.0
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
xml 3.5.0
Dev dependencies
flutter_test
test ^1.6.0

Admin