Git Product home page Git Product logo

flutter_svprogresshud's Introduction

flutter_svprogresshud

pub version

A clean and lightweight progress HUD for flutter app, based on SVProgressHUD.

The plugin supports almost all of SVProgressHUD APIs, for Android we have almost replicated SVProgressHUD effects (View code).


SVProgressHUD

Quick Start

Installation

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

dependencies:
  flutter_svprogresshud: ^1.0.1

You can install packages from the command line:

$ flutter pub get

Usage

(see demo in /example)

SVProgressHUD is created as a singleton (i.e. it doesn't need to be explicitly allocated and instantiated; you directly call SVProgressHUD.method()).

Use SVProgressHUD wisely! Only use it if you absolutely need to perform a task before taking the user forward. Bad use case examples: pull to refresh, infinite scrolling, sending message.

Using SVProgressHUD in your app will usually look as simple as this:

SVProgressHUD.show();
Future.delayed(Duration(seconds: 3)).then((value) {
  SVProgressHUD.dismiss();
});

Showing the HUD

You can show the status of indeterminate tasks using one of the following:

SVProgressHUD.show();
SVProgressHUD.show(status: 'Doing Stuff');

If you'd like the HUD to reflect the progress of a task, use one of these:

SVProgressHUD.showProgress(0.91);
SVProgressHUD.showProgress(0.91, status: 'Loading...');

Dismissing the HUD

The HUD can be dismissed using:

SVProgressHUD.dismiss()
SVProgressHUD.dismiss(delay: Duration(milliseconds: 2000));

If you'd like to stack HUDs, you can balance out every show call using:

+ (void)popActivity;

The HUD will get dismissed once the popActivity calls will match the number of show calls.

Or show a confirmation glyph before before getting dismissed a little bit later. The display time depends on minimumDismissTimeInterval and the length of the given string.

SVProgressHUD.showInfo(status: 'Useful Information.');
SVProgressHUD.showSuccess(status: 'Great Success!');
SVProgressHUD.showError(status: 'Failed with Error');

Customization

SVProgressHUD can be customized via the following methods:

void setDefaultStyle(SVProgressHUDStyle style);                 // default is SVProgressHUDStyle.Light
void setDefaultMaskType(SVProgressHUDMaskType maskType);        // default is SVProgressHUDMaskType.None
void setDefaultAnimationType(SVProgressHUDAnimationType type);  // default is SVProgressHUDAnimationType.Flat
void setMinimumSize(Size minimumSize);                          // default is Size.zero, can be used to avoid resizing
void setRingThickness(num width);                               // default is 2 pt
void setRingRadiu(num radius);                                  // default is 18 pt
void setRingNoTextRadius(num radius);                           // default is 24 pt
void setCornerRadius(num cornerRadius);                         // default is 14 pt
void setBorderColor(Color color);                               // default is null
void setBorderWidth(num width);                                 // default is 0
void setForegroundColor(Color color);                           // default is Colors.black, only used for SVProgressHUDStyle.Custom
// void setForegroundImageColor(Color color);                      // default is the same as foregroundColor
void setBackgroundColor(Color color);                           // default is Colors.white, only used for SVProgressHUDStyle.Custom
void setBackgroundLayerColor(Color color);                      // default is [Color colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskType.Custom
void setImageViewSize(Size size);                               // default is 28x28 pt
// void setShouldTintImages(bool shouldTintImages);                // default is true
// void setInfoImage(UIImage image);                               // default is the bundled info image provided by Freepik
// void setSuccessImage(UIImage image);                            // default is bundled success image from Freepik
// void setErrorImage(UIImage image);                              // default is bundled error image from Freepik
// void setGraceTimeInterval(num interval);                        // default is 0 seconds
void setMinimumDismissTimeInterval(num interval);               // default is 5.0 seconds
// void setMaximumDismissTimeInterval(num interval);               // default is CGFLOAT_MAX
void setFadeInAnimationDuration(num duration);                  // default is 0.15 seconds
void setFadeOutAnimationDuration(num duration);                 // default is 0.15 seconds
void setHapticsEnabled(bool hapticsEnabled);                    // default is false

Related Links

License

MIT

flutter_svprogresshud's People

Contributors

elceka avatar lijy91 avatar ycong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flutter_svprogresshud's Issues

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Float

SVProgressHUD.showProgress(100.0 / total * sent, "Sending picture..");

(total and sent are int)

E/MethodChannel#flutter_svprogresshud(25835): java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Float
E/MethodChannel#flutter_svprogresshud(25835): 	at org.blankapp.flutterplugins.flutter_svprogresshud.FlutterSvprogresshudPlugin.onMethodCall(FlutterSvprogresshudPlugin.java:42)
E/MethodChannel#flutter_svprogresshud(25835): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#flutter_svprogresshud(25835): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#flutter_svprogresshud(25835): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:643)
E/MethodChannel#flutter_svprogresshud(25835): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter_svprogresshud(25835): 	at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#flutter_svprogresshud(25835): 	at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#flutter_svprogresshud(25835): 	at android.app.ActivityThread.main(ActivityThread.java:6077)
E/MethodChannel#flutter_svprogresshud(25835): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_svprogresshud(25835): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/MethodChannel#flutter_svprogresshud(25835): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

SVProgressHUD customisation not working in Android.

Hi SVProgressHUD customisation is not working in iOS. Below is code and working is iOS but not working in Android. There's is always while background and

void showDefaultProgress() {
    SVProgressHUD.setDefaultMaskType(SVProgressHUDMaskType.custom);
    SVProgressHUD.setBackgroundColor(Colors.green);
    SVProgressHUD.setForegroundColor(Colors.pink);
    SVProgressHUD.setRingRadius(18);
    SVProgressHUD.setRingThickness(2.5);
    SVProgressHUD.setCornerRadius(10);
    SVProgressHUD.show();
  }

Null Safety Support

Hello
Thanks for your package, can you update support null safety flutter 2
Thanks

Crash due to unrecognised selector sent to instance

Calling SVProgressHUD.showSuccess(); leads to the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1fb1a7a88' terminating with uncaught exception of type NSException

This happens all the time

(see more in screenshot below)
Screenshot 2022-06-29 at 15 16 05

java.lang.Integer cannot be cast to java.lang.Double

E/MethodChannel#flutter_svprogresshud(13277): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
E/MethodChannel#flutter_svprogresshud(13277): 	at org.blankapp.flutterplugins.flutter_svprogresshud.FlutterSvprogresshudPlugin.onMethodCall(FlutterSvprogresshudPlugin.java:42)
E/MethodChannel#flutter_svprogresshud(13277): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/MethodChannel#flutter_svprogresshud(13277): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/MethodChannel#flutter_svprogresshud(13277): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:645)
E/MethodChannel#flutter_svprogresshud(13277): 	at android.os.MessageQueue.nativePollOnce(Native Method)

Code:

onProgressChanged: (InAppWebViewController controller, int progress) {
  SVProgressHUD.showProgress((progress / 100.0), "Loading...");
},

前来点赞。这个好用

最近我在用flutter写一个安卓iOS双端都能用的义工信息查询,刚好用到hud。感谢你的这个库。

Crash when running on Android 10

flutter_svprogresshud: ^0.0.6

[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
[!] Android Studio (version 4.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] VS Code (version 1.56.2)
E/flutter (27870): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method dismiss on channel flutter_svprogresshud)
E/flutter (27870): #0      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:157
E/flutter (27870): <asynchronous suspension>
E/flutter (27870): #1      MethodChannel.invokeMethod
package:flutter/…/services/platform_channel.dart:332
E/flutter (27870): #2      SVProgressHUD.dismiss
package:flutter_svprogresshud/src/svprogresshud.dart:38
E/flutter (27870): #3      _LoginPageState.loginBtnOnPress.<anonymous closure>
package:thrio_example/…/1.1_login_root/login_page.dart:87
E/flutter (27870): #4      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (27870): #5      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (27870): #6      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (27870): #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (27870): #8      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (27870): #9      Future._complete (dart:async/future_impl.dart:519:7)
E/flutter (27870): #10     new Future.delayed.<anonymous closure> (dart:async/future.dart:323:16)
E/flutter (27870): #11     _rootRun (dart:async/zone.dart:1182:47)
E/flutter (27870): #12     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27870): #13     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (27870): #14     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (27870): #15     _rootRun (dart:async/zone.dart:1190:13)
E/flutter (27870): #16     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (27870): #17     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
E/flutter (27870): #18     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (27870): #19     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
E/flutter (27870): #20     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
E/flutter (27870): #21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)


Error: MissingPluginException(No implementation found for method show on channel flutter_svprogresshud)

Hi everyone!

I got this error when the platform is Web

Error: MissingPluginException(No implementation found for method show on channel flutter_svprogresshud)

this the result of flutter doctor -v

[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.1105], locale en-US)
    • Flutter version 3.3.10 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (6 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\ahmed\AppData\Local\Android\sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32505.173
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.1
    • Flutter plugin version 70.0.4
    • Dart plugin version 221.5591.58

[√] VS Code (version 1.74.1)
    • VS Code at C:\Users\ahmed\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[√] Connected device (4 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Windows (desktop)                  • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.1105]
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 109.0.5414.75
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 109.0.1518.61

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

thanks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.