pub repository
mirror.p-hatan.comocto_image
2.1.2A multifunctional Flutter image widget. Supports placeholders, error widgets and image transformers with fading.
Showing cached metadata. Upstream refresh is currently unavailable.
Cached in Iran · upstream_checksum
Readme
OctoImage
An image library for showing placeholders, error widgets and transform your image.
Recommended using with CachedNetworkImage version 2.2.0 or newer.
Getting Started
The OctoImage widget needs an ImageProvider to show the image. You can either supply the widget with a placeholder or progress indicator, an ImageBuilder and/or an error widget.
However, what OctoImage makes is the use of OctoSets. OctoSets are predefined combinations of placeholders, imagebuilders and error widgets.
So, either set the all the components yourself:
OctoImage(
image: CachedNetworkImageProvider(
'https://blurha.sh/assets/images/img1.jpg'),
placeholderBuilder: OctoPlaceholder.blurHash(
'LEHV6nWB2yk8pyo0adR*.7kCMdnj',
),
errorBuilder: OctoError.icon(color: Colors.red),
fit: BoxFit.cover,
);
Or use an OctoSet:
OctoImage.fromSet(
fit: BoxFit.cover,
image: CachedNetworkImageProvider(
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Macaca_nigra_self-portrait_large.jpg/1024px-Macaca_nigra_self-portrait_large.jpg',
),
octoSet: OctoSet.circleAvatar(
backgroundColor: Colors.red,
text: Text("M"),
),
);
The CircleAvatar set shows a colored circle with the text inside during loading and when the image failed loading. When the image loads it animates to the image clipped as a circle.
ImageProviders
The recommended one is CachedNetworkImageProvider, as that supports the progress indicator, error and caching. It also works on Android, iOS, web and macOS, although without caching on the web. Make sure you use at least version 2.2.0.
The second best is NetworkImage, but any ImageProvider works in theory. However, for some ImageProviders (such as MemoryImage) it doesn't make sense to use OctoImage.
Placeholders and progress indicators
It would be best if you used either a placeholder or a progress indicator, but not both. Placeholders are only building once the image starts loading, but progress indicators are rebuilt every time new progress information is received. So if you don't use that progress indication, for example, with a static image, you should use a placeholder.
The most simple progress indicators use a CircularProgressIndicator.
OctoImage(
image: image,
progressIndicatorBuilder: (context) =>
const CircularProgressIndicator(),
),
OctoImage(
image: image,
progressIndicatorBuilder: (context, progress) {
double value;
if (progress != null && progress.expectedTotalBytes != null) {
value =
progress.cumulativeBytesLoaded / progress.expectedTotalBytes;
}
return CircularProgressIndicator(value: value);
},
),
However, because these are used so often, we prebuild these widgets for you. Just use OctoProgressIndicator.circularProgressIndicator()
OctoImage(
image: image,
progressIndicatorBuilder: OctoProgressIndicator.circularProgressIndicator(),
),
All included placeholders and progress indicators:
| OctoPlaceholder | Explanation |
|---|---|
| blurHash | Shows a BlurHash image |
| circleAvatar | Shows a colored circle with a text |
| circularProgressIndicator | Shows a circularProgressIndicator with indeterminate progress. |
| frame | Shows the Flutter Placeholder |
| OctoProgressIndicator | Explanation |
|---|---|
| circularProgressIndicator | Shows a simple CircularProgressIndicator |
Error widgets
Error widgets are shown when the ImageProvider throws an error because the image failed loading. You can build a custom widget, or use the prebuild widgets:
OctoImage(
image: image,
errorBuilder: (context, error, stacktrace) =>
const Icon(Icons.error),
);
OctoImage(
image: image,
errorBuilder: OctoError.icon(),
),
All included error widgets are:
| OctoError | Explanation |
|---|---|
| blurHash | Shows a BlurHash placeholder with an error icon. |
| circleAvatar | Shows a colored circle with a text |
| icon | Shows an icon, default to Icons.error |
| placeholderWithErrorIcon | Shows any placeholder with an icon op top. |
Image builders
Image builders can be used to adapt the image before it is shown. For example the circleAvatar clips the image in a circle, but you could also add an overlay or anything else.
The builder function supplies a context and a child. The child is the image widget that is rendered.
An example that shows the image with 50% opacity:
OctoImage(
image: image,
imageBuilder: (context, child) => Opacity(
opacity: 0.5,
child: child,
),
),
A prebuild image transformer that clips the image as a circle:
OctoImage(
image: image,
imageBuilder: OctoImageTransformer.circleAvatar(),
),
All included image transformers are:
| OctoImageTransformer | Explanation |
|---|---|
| circleAvatar | Clips the image in a circle |
OctoSets
You get the most out of OctoImage when you use OctoSets. These sets contain a combination of a placeholder or progress indicator, an image builder and/or an error widget builder. It always contains at least a placeholder or progress indicator and an error widget.
You can use them with OctoImage.fromSet:
OctoImage.fromSet(
image: image,
octoSet: OctoSet.circleAvatar(backgroundColor: Colors.red, text: Text("M")),
),
All included OctoSets are:
| OctoSet | Explanation |
|---|---|
| circleAvatar | Shows a colored circle with text during load and error. Clips the image after successful load. |
| circularIndicatorAndIcon | Shows a circularProgressIndicator with or without progress and an icon on error. |
Blurhash
You can easily create your own OctoSet though, for example if you want to use blurHash as a placeholder:
/// Simple set to show [OctoPlaceholder.circularProgressIndicator] as
/// placeholder and [OctoError.icon] as error.
OctoSet blurHash(
String hash, {
BoxFit? fit,
Text? errorMessage,
}) {
return OctoSet(
placeholderBuilder: blurHashPlaceholderBuilder(hash, fit: fit),
errorBuilder: blurHashErrorBuilder(hash, fit: fit),
);
}
OctoPlaceholderBuilder blurHashPlaceholderBuilder(String hash, {BoxFit? fit}) {
return (context) => SizedBox.expand(
child: Image(
image: BlurHashImage(hash),
fit: fit ?? BoxFit.cover,
),
);
}
OctoErrorBuilder blurHashErrorBuilder(
String hash, {
BoxFit? fit,
Text? message,
IconData? icon,
Color? iconColor,
double? iconSize,
}) {
return OctoError.placeholderWithErrorIcon(
blurHashPlaceholderBuilder(hash, fit: fit),
message: message,
icon: icon,
iconColor: iconColor,
iconSize: iconSize,
);
}
Contribute
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our contribution guide and send us your pull request.
PR's with any new prebuild widgets or sets are highly appreciated.
Support
- Feel free to open an issue. Make sure to use one of the templates!
- Commercial support is available. Integration with your app or services, samples, feature request, etc. Email: hello@baseflow.com
- Powered by: baseflow.com
Changelog
[2.1.2] - 2026-09-29
- Update
flutter_lintsto 6.0.0 in the package and the example app. - Update the example app's
httpdependency to 1.6.0.
[2.1.1] - 2026-09-23
- Fix the README build badge and demo image, which pointed at a retired CI service and a branch that no longer exists.
- Fix the example app's SDK and
flutter_lintsconstraints, which excluded every SDK the package supports. - Update the example app's Android build to AGP 9.
- Pin the Flutter version used in CI and move the repository to a
main-only branching model.
[2.1.0] - 2024-08-01
- Raise the minimum SDK to Dart 3.0 and Flutter 3.10.
alignmentacceptsAlignmentGeometry, soAlignmentDirectionalcan be used.- Fix the fading-out widget never being removed when
fadeOutDurationisDuration.zero(issue 34).
[2.0.0] - 2023-09-25
- Remove Blurhash dependency, see in the readme how to keep using blurhash.
[1.0.2] - 2022-05-16
- Update Blurhash dependency
[1.0.1] - 2021-11-30
- Fix gapless playback when next image is already in memory.
[1.0.0+1] - 2021-04-02
- Remove unused import
[1.0.0] - 2021-03-27
- Fixes "Cannot clone a disposed image" error
- Migration to nullsafety
[1.0.0-nullsafety.1] - 2021-01-15
- Re-enabled blurhash features.
[1.0.0-nullsafety.0] - 2021-01-14
- NNBD migrated version
- (Temporarily) removed blurhash feature.
[0.3.0] - 2020-09-07
- Fixed bug when fitting placeholders or error widgets.
- BREAKING: Doesn't automatically center placeholders and error widgets anymore.
[0.2.1] - 2020-06-04
- Make whole widget, including placeholder and error widgets, adhere to the height and width set.
[0.2.0] - 2020-05-28
- Made gaplessPlayback fade from one image to the next
[0.1.1] - 2020-05-20
- Update dependency for blurHash
[0.1.0] - 2020-05-14
- Removed headers as they are not used for anything
- Added gaplessPlayback, works just like in Image: it keeps the old image visible when a new image is being loaded by the same widget.
- Changed how default parameter values work preventing setting them to null.
[0.0.1] - 2020-05-08
- Initial release with already lots of great features :)
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add octo_imagepubspec.yaml
name: octo_image
description: A multifunctional Flutter image widget. Supports placeholders, error widgets and image transformers with fading.
version: 2.1.2
homepage: https://github.com/Baseflow/octo_image
environment:
sdk: '>=3.0.0 <4.0.0'
flutter: '>=3.10.0'
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.1 | 2020-05-08T12:52:36.874260Z | Cached | 21e2d8ade4a887c8413ba6bdc9fb60cc402988d084cb288b6e44a56e774484b1 |
| 0.1.0 | 2020-05-14T15:04:15.190231Z | Cached | 24b434310b1a86be9b87fdf539de577b2961c7acea49dc86e0ae5f5ed7f51e67 |
| 0.1.1 | 2020-05-20T14:12:03.857320Z | Cached | d496a4705193762513d36a51bcabf7da29f1bb60d66ac40c74e5d7c3d16ea73b |
| 0.2.0 | 2020-05-28T12:08:34.909456Z | Cached | 2a4b0ea991040bb7ffe4bcb944f053ef70570aef801a56ce688026f8e31288bc |
| 0.2.1 | 2020-06-04T09:20:07.970929Z | Cached | a88e608689403a832f4f8a4ffc55b3a5ae8ea9f82cf24036a9c889352e592802 |
| 0.3.0 | 2020-09-07T06:50:41.937826Z | Cached | a261b7ac13f1129286e07206264f0df66d233f9aac3381566e09a5c0dfc30652 |
| 1.0.0-nullsafety.0 | 2021-01-14T14:16:22.605162Z | Cached | 0ae924df9bb55bf88238bc08deb7085309fced4f7653f797e64c0f387a6dc57d |
| 1.0.0-nullsafety.1 | 2021-01-15T08:20:12.167531Z | Cached | ab4fbcd0e0bb5633d601f8016487ebb4e6502c186ce0dcbd2def367e613ebc0b |
| 1.0.0 | 2021-03-27T12:30:11.908443Z | Cached | c4723cc22c047ba56f58a35402b9b9f984dfb91d6b2e92809433a9647312cbf8 |
| 1.0.0+1 | 2021-04-02T13:03:37.615808Z | Cached | 33894db83453d13a6f48635af015f85fb24892536cd6a5d3bd2b24606b9ab527 |
| 1.0.1 | 2021-11-30T16:50:22.227672Z | Cached | a4d69f0677d742a5c76b26430aeae9420656226f8b6add0f3d9a7c6309f35012 |
| 1.0.2 | 2022-05-16T17:57:34.973190Z | Cached | 107f3ed1330006a3bea63615e81cf637433f5135a52466c7caa0e7152bca9143 |
| 2.0.0 | 2023-09-25T13:48:33.198816Z | Cached | 45b40f99622f11901238e18d48f5f12ea36426d8eced9f4cbf58479c7aa2430d |
| 2.1.0 | 2024-08-01T17:30:56.265130Z | Cached | 34faa6639a78c7e3cbe79be6f9f96535867e879748ade7d17c9b1ae7536293bd |
| 2.1.1 | 2026-09-23T19:25:51.729423Z | Cached | 66e8f59a538a9f9f53141bc22ec0a12f8e85f2ca3bfcacab6dd30315b2fc256d |
| 2.1.2 | 2026-09-30T09:09:57.014674Z | Cached | 49c4f93afc10f1ad4fdef9db88fed9c65a8eb5d9ad0a4fa9b128d7fedeb41418 |
Dependencies
flutter {
"sdk": "flutter"
}