Skip to content

Repository files navigation

Flutter EasyLoading

pub packageCIpub pointslikeslicense

🌐 English | 简体中文

A lightweight, customizable loading, progress, result, and toast overlay for Flutter. Display calls do not require a BuildContext.

  • Loading, determinate progress, result states, and toast messages
  • Global calls without passing a BuildContext
  • Built-in indicators, custom widgets, and custom transitions
  • Global defaults with immutable per-call overrides
  • Material and Cupertino application support

🎬 Preview

Loading indicator previewProgress previewResult previewToast preview

Open the interactive Flutter EasyLoading preview

🧰 Requirements

  • Dart 3.6.0 or later, below Dart 4.0.0
  • Flutter 3.27.0 or later

Read the 4.0 migration guide before upgrading from 3.x.

📦 Installation

flutter pub add flutter_easyloading

Or add the dependency manually:

dependencies:
flutter_easyloading: ^4.0.2
import'package:flutter_easyloading/flutter_easyloading.dart';

🚀 Quick Start

Install one EasyLoading Host at the root MaterialApp or CupertinoApp:

MaterialApp(
builder:EasyLoading.init(),
home:constHomePage(),
);

Display and dismiss content from anywhere after the Host is mounted:

awaitEasyLoading.show(status:'Loading...');
awaitEasyLoading.showProgress(0.5, status:'Downloading...');
awaitEasyLoading.showSuccess('Completed');
awaitEasyLoading.showError('Request failed');
awaitEasyLoading.showInfo('Update available');
awaitEasyLoading.showToast('Saved');
awaitEasyLoading.dismiss();

All display and dismissal methods return Future<void> and can be awaited.

If the application already has a root builder, compose it through init:

MaterialApp(
builder:EasyLoading.init(
builder: (context, child) =>ExistingRoot(child: child),
),
home:constHomePage(),
);

📖 API Reference

Initialization and state

APIReturnsDescription
EasyLoading()EasyLoadingReturns the shared configuration instance.
EasyLoading.instanceEasyLoadingAccesses the shared configuration instance.
EasyLoading.isShowboolReports whether an EasyLoading overlay is active.
EasyLoading.init({builder})TransitionBuilderCreates the application-level Host builder and optionally composes another builder.
FlutterEasyLoading(child: child)FlutterEasyLoadingCreates the Host widget directly. Most applications should use EasyLoading.init().

Display and dismissal

APIParametersDescription
EasyLoading.show(...)status, indicator, maskType, dismissOnTap, duration, optionsShows or updates an indeterminate loading indicator.
EasyLoading.showProgress(value, ...)status, maskType, indicator, duration, dismissOnTap, optionsShows or updates determinate progress from 0.0 to 1.0.
EasyLoading.showSuccess(status, ...)duration, maskType, dismissOnTap, optionsShows a success result.
EasyLoading.showError(status, ...)duration, maskType, dismissOnTap, optionsShows an error result.
EasyLoading.showInfo(status, ...)duration, maskType, dismissOnTap, optionsShows an information result.
EasyLoading.showToast(status, ...)duration, toastPosition, maskType, dismissOnTap, optionsShows a text-only toast.
EasyLoading.showCustom(content, ...)duration, maskType, dismissOnTap, optionsShows arbitrary widget content.
EasyLoading.dismiss({animation})animation defaults to trueDismisses the active overlay.

Callbacks

APIDescription
EasyLoading.addStatusCallback(callback)Adds an EasyLoadingStatusCallback.
EasyLoading.removeCallback(callback)Removes one status callback.
EasyLoading.removeAllCallbacks()Removes every status callback.
EasyLoading.addDismissCallback(callback)Adds an EasyLoadingDismissCallback.
EasyLoading.removeDismissCallback(callback)Removes one dismissal callback.
EasyLoading.removeAllDismissCallbacks()Removes every dismissal callback.
voidonStatus(EasyLoadingStatus status) {
// EasyLoadingStatus.show or EasyLoadingStatus.dismiss
}
voidonDismiss(EasyLoadingDismissReason reason) {
// programmatic, tap, timeout, or hostDetached
}
EasyLoading.addStatusCallback(onStatus);
EasyLoading.addDismissCallback(onDismiss);
// Remove callbacks when their owner is disposed.EasyLoading.removeCallback(onStatus);
EasyLoading.removeDismissCallback(onDismiss);

⚙️ Configuration

Set global defaults once during application startup:

EasyLoading.instance
..loadingStyle =EasyLoadingStyle.dark
..indicatorType =EasyLoadingIndicatorType.fadingCircle
..maskType =EasyLoadingMaskType.none
..toastPosition =EasyLoadingToastPosition.bottom
..displayDuration =constDuration(seconds:2)
..animationDuration =constDuration(milliseconds:200);

General

PropertyTypeDefaultDescription
loadingStyleEasyLoadingStyledarkPanel color style.
indicatorTypeEasyLoadingIndicatorTypefadingCircleBuilt-in loading indicator.
maskTypeEasyLoadingMaskTypenoneDefault barrier style and interaction mode.
toastPositionEasyLoadingToastPositioncenterDefault toast placement.
animationStyleEasyLoadingAnimationStyleopacityPanel transition style.
displayDurationDuration2000 msDefault result and toast duration.
animationDurationDuration200 msPresentation and dismissal transition duration.
userInteractionsbool?nullOptional override for input reaching the application below the overlay.
dismissOnTapbool?null (false)Default tap-to-dismiss override.

Layout and text

PropertyTypeDefaultDescription
textAlignTextAligncenterStatus text alignment.
contentPaddingEdgeInsetsvertical: 15, horizontal: 20Panel content padding.
textPaddingEdgeInsetsbottom: 10Space between the indicator and status text.
indicatorSizedouble40Built-in indicator width and height.
radiusdouble5Panel corner radius.
fontSizedouble15Status font size when textStyle is not set.
progressWidthdouble2Determinate progress stroke width.
lineWidthdouble4Stroke width for supported built-in indicators.
textStyleTextStyle?nullComplete status text style.

Colors and effects

PropertyTypeDefaultDescription
textColorColor?nullStatus color for EasyLoadingStyle.custom.
indicatorColorColor?nullIndicator color for EasyLoadingStyle.custom.
progressColorColor?nullProgress color for EasyLoadingStyle.custom.
backgroundColorColor?nullPanel color for EasyLoadingStyle.custom.
boxShadowList<BoxShadow>?nullPanel shadows for EasyLoadingStyle.custom.
maskColorColor?nullBarrier color for EasyLoadingMaskType.custom.

Custom widgets and animation

PropertyTypeDefaultDescription
customAnimationEasyLoadingAnimation?nullTransition used by EasyLoadingAnimationStyle.custom.
indicatorWidgetWidget?nullGlobal replacement for the loading indicator.
successWidgetWidget?nullGlobal replacement for the success icon.
errorWidgetWidget?nullGlobal replacement for the error icon.
infoWidgetWidget?nullGlobal replacement for the information icon.

Custom modes require their corresponding values:

  • EasyLoadingStyle.custom: backgroundColor, indicatorColor, and textColor; progress also requires progressColor.
  • EasyLoadingMaskType.custom: maskColor.
  • EasyLoadingAnimationStyle.custom: customAnimation.

🎛️ Per-call Options

EasyLoadingOptions is an immutable snapshot for one display call. Every field is optional and inherits the corresponding global value when omitted.

GroupSupported fields
AppearanceloadingStyle, indicatorType, animationStyle, backgroundColor, boxShadow
Indicator and progressindicatorSize, indicatorColor, progressColor, progressWidth, lineWidth
TexttextAlign, textStyle, textColor, fontSize, textPadding
Layoutalignment, constraints, contentPadding, radius
AnimationanimationDuration, customAnimation
Mask and interactionmaskColor, userInteractions

maskType, dismissOnTap, and duration remain direct method parameters. toastPosition is a direct parameter of showToast.

awaitEasyLoading.show(
status:'Uploading',
maskType:EasyLoadingMaskType.black,
duration:constDuration(seconds:10),
options:constEasyLoadingOptions(
loadingStyle:EasyLoadingStyle.auto,
alignment:AlignmentDirectional.topEnd,
constraints:BoxConstraints(maxWidth:320),
indicatorType:EasyLoadingIndicatorType.ring,
),
);

🧩 Public Types

TypeValues or purpose
EasyLoadingStylelight, dark, custom, auto
EasyLoadingToastPositiontop, center, bottom
EasyLoadingAnimationStyleopacity, offset, scale, custom
EasyLoadingMaskTypenone, clear, black, custom
EasyLoadingIndicatorType30 built-in indicators listed below.
EasyLoadingStatusshow, dismiss
EasyLoadingDismissReasonprogrammatic, tap, timeout, hostDetached
EasyLoadingStatusCallbackvoid Function(EasyLoadingStatus status)
EasyLoadingDismissCallbackvoid Function(EasyLoadingDismissReason reason)
EasyLoadingOptionsImmutable visual and layout overrides for one call.
EasyLoadingAnimationBase class for custom transitions; implement buildWidget.
FlutterEasyLoadingApplication-level Host widget created by EasyLoading.init().
All EasyLoadingIndicatorType values

fadingCircle, circle, threeBounce, chasingDots, wave, wanderingCubes, rotatingPlain, doubleBounce, fadingFour, fadingCube, pulse, cubeGrid, rotatingCircle, foldingCube, pumpingHeart, dualRing, hourGlass, pouringHourGlass, fadingGrid, ring, ripple, spinningCircle, squareCircle, dancingSquare, pianoWave, pouringHourGlassRefined, pulsingGrid, spinningLines, threeInOut, and waveSpinner.

🎨 Custom Content

awaitEasyLoading.showCustom(
constMaterial(
child:Padding(
padding:EdgeInsets.all(16),
child:Text('Custom content'),
),
),
maskType:EasyLoadingMaskType.black,
options:constEasyLoadingOptions(
alignment:AlignmentDirectional.bottomCenter,
constraints:BoxConstraints(maxWidth:320),
),
);

See the example application's custom animation for an EasyLoadingAnimation implementation.

🔄 Migrating From 3.x

Common init, show..., dismiss, status callback, and EasyLoading.instance call forms remain valid. Review the SDK baseline and removed undocumented internals in the 4.0 migration guide.

🗂️ Project

⚖️ License

Flutter EasyLoading is available under the MIT License.

🙏 Credits

Built-in loading indicators are provided by flutter_spinkit.

About

✨A clean and lightweight loading/toast widget for Flutter, easy to use without context, support iOS、Android and Web

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1.3k stars

Watchers

8 watching

Forks

Releases

Used by

Contributors

Languages