ok_image 0.4.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

OKImage #

Easy to use this library to build a network image widget, you can build different layouts according to the error/load, also set up the image cache delegate.

ok_image pub package GitHub GitHub stars

use #

  1. add to your pubspec.yaml
ok_image: ^0.4.0
  1. import
import "package:ok_image/ok_image.dart";
  1. use
import "package:ok_image/ok_image.dart";
  return OKImage(
      url: "https://ws1.sinaimg.cn/large/844036b9ly1fxfo76hzd4j20zk0nc48i.jpg",
      width: 200,
      height: 200,
      timeout: Duration(seconds: 20),
      fit: fit,
  1. params
url: image net url
width: width
height: height
fit: show BoxFit
followRedirects: whether image redirection is allowed.
loadingWidget: display on loading
errorWidget: display when image load error / timeout.
retry: retry to load image count.
timeout: timeout duration.
onErrorTap: when loadErrorWidget show ,onTap it.
cacheDelegate: you can use the param to delegate loadImage

Experimental: Signatures, return values, parameters and other information may be modified in the future.

onLoadStateChanged: will be call on the load state changed.
  1. global config

edit OKImage.buildErrorWidget to config global OKImage errorWidget.

edit OKImage.buildLoadingWidget to config global OKImage loading.

about other library #

under BSD 3:

  1. This library uses http 0.12.0+2 as a framework for network access.
  2. using path_provider 1.2.0 to get default catch path.
  3. using crypto 2.0.6 to make and check md5.

Apache 2.0:

  1. Using rxdart 0.22.1 processing logic

thanks to open source.

If you are using older versions of these open source libraries, which cause incompatibility, please update your. If it is incompatible with me, please contact me and I will update the version number when appropriate.



Breaking change: Params errorWidget change type to ErrorWidgetBuilder.


  • Download error bug.

[0.3.1] upgrade dependencies version

  • path_provider
  • rx_dart
  • http

[0.3.0] upgrade path_provider

breaking change because path_provider migrate from android support to androidX, so your other plugin also need be migrated. upgrade rxdart

[0.2.3] add remove cache

ImageCache.removeCache(String url);

[0.2.2] request

add a parameter to delete the cache whose last access time exceeds duration

add onImageLoadState callback

[0.2.1] un-ext image load error

Fix: Unextended images cannot be loaded


global error and loading widget

add a clear cache method

upgrade rxdart version

fix bug for downloading

[0.1.1] fix load bug

fix error bug

[0.1.0] update request and cache

Now the same URL will share a download, waiting for the download to complete and return together.

+1 #

update readme

[0.0.3] add cache delegate

add a default cache delegate to cache image


use MIT

[0.0.1] first version


example #

A new Flutter project.

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:

  ok_image: ^0.4.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:ok_image/ok_image.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (rxdart).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
crypto ^2.0.6 2.1.4
flutter 0.0.0
http ^0.12.0+2 0.12.0+4
path_provider ^1.2.0 1.5.1
rxdart ^0.22.1 0.22.6 0.23.1
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
convert 2.1.1
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
platform 2.2.1
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies