All Projects → Baseflow → Octo_image

Baseflow / Octo_image

Licence: mit
A multifunctional Flutter image widget

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Octo image

Firebase auth ui
Flutter plugin for Firebase Auth UI. Supports popular auth providers by using native SDK for Android and iOS.
Stars: ✭ 44 (-54.64%)
Mutual labels:  flutter-plugin
Flutter Permission Handler
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
Stars: ✭ 1,144 (+1079.38%)
Mutual labels:  flutter-plugin
Flutter plugin pdf viewer
A flutter plugin for handling PDF files. Works on both Android & iOS
Stars: ✭ 81 (-16.49%)
Mutual labels:  flutter-plugin
Math Metrix
This is Math-Puzzle game made in flutter and available on Playstore & AppStore
Stars: ✭ 48 (-50.52%)
Mutual labels:  flutter-plugin
Flutter appavailability
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
Stars: ✭ 63 (-35.05%)
Mutual labels:  flutter-plugin
Flutter Otp Authentication
A Flutter based OTP Authentication component, used to verify your mobile number with OTP (One Time Password) using Firebase Authentication.
Stars: ✭ 78 (-19.59%)
Mutual labels:  flutter-plugin
Fluttermidicommand
A Flutter plugin to send and receive MIDI
Stars: ✭ 41 (-57.73%)
Mutual labels:  flutter-plugin
Flutter inappwebview
A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
Stars: ✭ 1,259 (+1197.94%)
Mutual labels:  flutter-plugin
Stereo
A Flutter plugin for playing music on iOS and Android.
Stars: ✭ 66 (-31.96%)
Mutual labels:  flutter-plugin
Flutter web auth
Flutter plugin for authenticating a user with a web service
Stars: ✭ 81 (-16.49%)
Mutual labels:  flutter-plugin
Flutterradioplayer
Flutter Radio Player, A Plugin to handle streaming audio without a hassle
Stars: ✭ 59 (-39.18%)
Mutual labels:  flutter-plugin
Flutter native ads
Show AdMob Native Ads use PlatformView
Stars: ✭ 63 (-35.05%)
Mutual labels:  flutter-plugin
Intent
A simple Flutter plugin to deal with Android Intents, written with ❤️
Stars: ✭ 79 (-18.56%)
Mutual labels:  flutter-plugin
Dlna Dart
A simple DLNA DMC library implemented by Dart.
Stars: ✭ 46 (-52.58%)
Mutual labels:  flutter-plugin
Json to form
A flutter plugin to use convert Json to Form
Stars: ✭ 82 (-15.46%)
Mutual labels:  flutter-plugin
Flutter branch sdk
Flutter Plugin for create deep link using Brach Metrics SDK. This plugin provides a cross-platform (iOS, Android).
Stars: ✭ 43 (-55.67%)
Mutual labels:  flutter-plugin
Flutter install plugin
A flutter plugin for install apk for android; and using url to go to app store for iOS.
Stars: ✭ 71 (-26.8%)
Mutual labels:  flutter-plugin
Flutter weather bg
A rich and cool weather dynamic background plug-in
Stars: ✭ 89 (-8.25%)
Mutual labels:  flutter-plugin
In app review
A Flutter plugin for showing the In-App Review/System Rating pop up on Android, IOS, and MacOS. It makes it easy for users to rate your app.
Stars: ✭ 85 (-12.37%)
Mutual labels:  flutter-plugin
Firebase dart sdk
Unofficial Firebase Flutter SDK. Maintainer: @long1eu
Stars: ✭ 80 (-17.53%)
Mutual labels:  flutter-plugin

OctoImage

pub package Build Status codecov

An image library for showing placeholders, error widgets and transform your image.

Recommended to use 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 placholders, 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 web. Make sure you use at least version 2.2.0.

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

You should use either a placeholder or a progress indicator, but not both. Placeholders are only build once when the image starts loading, but progress indicators are rebuild every time new progress information is received. So if you don't use that progress indication, for example with a static image, than 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.blurHash('LEHV6nWB2yk8pyo0adR*.7kCMdnj'),
),

All included OctoSets are:

OctoSet Explanation
blurHash Shows a blurhash as placeholder and error widget. When an error is thrown an icon is shown on top.
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.

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: [email protected]
  • Powered by: baseflow.com
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].