extended_image 0.1.7

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new63

extended_image #

pub package

extended official image with load state,crop,save,clip,paint etc.

Chinese bolg

extended image is the same as official image.

Cache network image #

You can use ExtendedNetworkImageProvider

 ExtendedNetworkImageProvider(this.url,
      {this.scale = 1.0,
      this.headers,
      this.cache: false,
      this.retries = 3,
      this.timeLimit,
      this.timeRetry = const Duration(milliseconds: 100)})
      : assert(url != null),
        assert(scale != null);

  ///time Limit to request image
  final Duration timeLimit;

  ///the time to retry to request
  final int retries;

  ///the time duration to retry to request
  final Duration timeRetry;

  ///whether cache image to local
  final bool cache;

  /// The URL from which the image will be fetched.
  final String url;

  /// The scale to place in the [ImageInfo] object of the image.
  final double scale;

  /// The HTTP headers that will be used with [HttpClient.get] to fetch image from network.
  final Map<String, String> headers;  

More: timeRetry/retries/timeLimit are used for request parameter

or just use with following code

ExtendedImage.network(
                url,
                width: ScreenUtil.instance.setWidth(400),
                height: ScreenUtil.instance.setWidth(400),
                fit: BoxFit.fill,
                cache: true,
                border: Border.all(color: Colors.red, width: 1.0),
                shape: boxShape,
                borderRadius: BorderRadius.all(Radius.circular(30.0)),
              ),

Circle/BorderRadius/Border #

Circle/BorderRadius/Border are easy to be used.

ExtendedImage.network(
                url,
                width: ScreenUtil.instance.setWidth(400),
                height: ScreenUtil.instance.setWidth(400),
                fit: BoxFit.fill,
                cache: true,
                border: Border.all(color: Colors.red, width: 1.0),
                shape: boxShape,
                borderRadius: BorderRadius.all(Radius.circular(30.0)),
              ),

Clear and Save #

Clear disk cached , you can set duration to clear expired images or clear all of them.

// Clear the disk cache directory then return if it succeed.
///  <param name="duration">timespan to compute whether file has expired or not</param>
Future<bool> clearDiskCachedImages({Duration duration}) 
///clear all of image in memory
 clearMemoryImageCache();

/// get ImageCache
 getMemoryImageCache() ;
saveNetworkImageToPhoto(String url, {bool useCache: true})

Custom load state #

/// custom load state widget if you want
final LoadStateChanged loadStateChanged;

provide LoadStateChanged function to build custom load widget, it's not just for network image, if your image need long to load, you can define your loading widget or crop your image at that moment. see custom image demo

  ExtendedImage.network(
                  url,
                  width: ScreenUtil.instance.setWidth(600),
                  height: ScreenUtil.instance.setWidth(400),
                  fit: BoxFit.fill,
                  cache: true,
                  loadStateChanged: (ExtendedImageState state) {
                    switch (state.extendedImageLoadState) {
                      case LoadState.loading:
                        _controller.reset();
                        return Image.asset(
                          "assets/loading.gif",
                          fit: BoxFit.fill,
                        );
                        break;
                      case LoadState.completed:
                        _controller.forward();
                        return FadeTransition(
                          opacity: _controller,
                          child: ExtendedRawImage(
                            image: state.extendedImageInfo?.image,
                            width: ScreenUtil.instance.setWidth(600),
                            height: ScreenUtil.instance.setWidth(400),
                          ),
                        );
                        break;
                      case LoadState.failed:
                        _controller.reset();
                        return GestureDetector(
                          child: Stack(
                            fit: StackFit.expand,
                            children: <Widget>[
                              Image.asset(
                                "assets/failed.jpg",
                                fit: BoxFit.fill,
                              ),
                              Positioned(
                                bottom: 0.0,
                                left: 0.0,
                                right: 0.0,
                                child: Text(
                                  "load image failed, click to reload",
                                  textAlign: TextAlign.center,
                                ),
                              )
                            ],
                          ),
                          onTap: () {
                            state.reLoadImage();
                          },
                        );
                        break;
                    }
                  },
                )

Crop image #

you can crop image with ExtendedRawImage, soureRect is which you want to show image rect. crop image demo

ExtendedRawImage(
        image: image,
        width: num400,
        height: num300,
        fit: BoxFit.fill,
        soucreRect: Rect.fromLTWH(
            (image.width - width) / 2.0, 0.0, width, image.height.toDouble()),
      )

paint any thing if you want when image is ready #

provide BeforePaintImage and AfterPaintImage, you will have the chance to paint thing you want. see paint image demo and push to refresh header which is used in crop image demo

 ExtendedImage.network(
                 url,
                 width: ScreenUtil.instance.setWidth(400),
                 height: ScreenUtil.instance.setWidth(400),
                 fit: BoxFit.fill,
                 cache: true,
                 beforePaintImage: (Canvas canvas, Rect rect, ui.Image image) {
                   if (paintType == PaintType.ClipHeart) {
                     if (!rect.isEmpty) {
                       canvas.save();
                       canvas.clipPath(clipheart(rect, canvas));
                     }
                   }
                   return false;
                 },
                 afterPaintImage: (Canvas canvas, Rect rect, ui.Image image) {
                   if (paintType == PaintType.ClipHeart) {
                     if (!rect.isEmpty) canvas.restore();
                   } else if (paintType == PaintType.PaintHeart) {
                     canvas.drawPath(
                         clipheart(rect, canvas),
                         Paint()
                           ..colorFilter = ColorFilter.mode(
                               Color(0x55ea5504), BlendMode.srcIn)
                           ..isAntiAlias = false
                           ..filterQuality = FilterQuality.low);
 
 //                    canvas.drawImageRect(
 //                        image,
 //                        Rect.fromLTWH(0.0, y, imageWidth, imageHeight - y),
 //                        Rect.fromLTWH(
 //                            rect.left,
 //                            rect.top + y / imageHeight * size.height,
 //                            size.width,
 //                            (imageHeight - y) / imageHeight * size.height),
 //                        Paint()
 //                          ..colorFilter = ColorFilter.mode(
 //                              Color(0x22ea5504), BlendMode.srcIn)
 //                          ..isAntiAlias = false
 //                          ..filterQuality = FilterQuality.low);
                   }
                 },
               )

[0.1.7]

  • public instantiateImageCodec method so that you can handle image data by override this in ExtendedNetworkImageProvider

[0.1.6]

  • add getNetworkImageData method

[0.1.5]

  • change toMd5 to keyToMd5

[0.1.4]

  • public imageProvider for ExtendedImageState

[0.1.3]

  • add extended image.

example/README.md

example #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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


dependencies:
  extended_image: ^0.1.7

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:extended_image/extended_image.dart';
  
Version Uploaded Documentation Archive
0.1.7 Mar 20, 2019 Go to the documentation of extended_image 0.1.7 Download extended_image 0.1.7 archive
0.1.6 Mar 20, 2019 Go to the documentation of extended_image 0.1.6 Download extended_image 0.1.6 archive
0.1.5 Mar 20, 2019 Go to the documentation of extended_image 0.1.5 Download extended_image 0.1.5 archive
0.1.4 Mar 18, 2019 Go to the documentation of extended_image 0.1.4 Download extended_image 0.1.4 archive
0.1.3 Mar 11, 2019 Go to the documentation of extended_image 0.1.3 Download extended_image 0.1.3 archive
0.1.2 Mar 11, 2019 Go to the documentation of extended_image 0.1.2 Download extended_image 0.1.2 archive
0.1.1 Mar 11, 2019 Go to the documentation of extended_image 0.1.1 Download extended_image 0.1.1 archive
0.1.0 Mar 11, 2019 Go to the documentation of extended_image 0.1.0 Download extended_image 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
26
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]
63
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.3.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev.68.0 <3.0.0
crypto ^2.0.6 2.0.6
flutter 0.0.0
http_client_helper ^0.1.7 0.1.7
image_picker_saver ^0.1.0 0.1.0
path_provider ^0.4.1 0.4.1 0.5.0+1
transparent_image ^0.1.0 0.1.0 1.0.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http 0.12.0+1
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
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
Dev dependencies
flutter_test