ovprogresshud 0.1.1 copy "ovprogresshud: ^0.1.1" to clipboard
ovprogresshud: ^0.1.1 copied to clipboard

discontinued
outdated

A useful Hud framework is implemented by calling native code by Flutter. With one line of code, you can call Hud out anywhere and control its hiding. In the example App, you can see how to use it. SVP [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:ovprogresshud/progresshud.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Progresshud.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      // _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Progress example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              button('show', () async {
                await Progresshud.show();
              }),
              button('showWithStatus', () async {
                await Progresshud.showWithStatus('myinfo');
              }),
              button('showInfoWithStatus', () async {
                await Progresshud.showInfoWithStatus('myinfo');
              }),
              button('showErrorWithStatus', () async {
                await Progresshud.showErrorWithStatus('myinfo');
              }),
              button('showSuccessWithStatus', () async {
                await Progresshud.showSuccessWithStatus('myinfo');
              }),
              // button('setDefaultStyleDark', () async {
              //   await Progresshud.setDefaultStyleDark();
              // }),
              // button('setDefaultStyleLight', () async {
              //   await Progresshud.setDefaultStyleLight();
              // }),
              button('setDefaultMaskTypeNone', () async {
                await Progresshud.setDefaultMaskTypeNone();
              }),
              button('setDefaultMaskTypeBlack', () async {
                await Progresshud.setDefaultMaskTypeBlack();
              }),
              button('setDefaultMaskTypeClear', () async {
                await Progresshud.setDefaultMaskTypeClear();
              }),
              button('setDefaultMaskTypeGradient', () async {
                await Progresshud.setDefaultMaskTypeGradient();
              }),
              button('dismiss', () async {
                await Progresshud.dismiss();
              }),
            ],
          ),
        ),
      ),
    );
  }

  Timer dismissTimer;

  Widget button(String title, VoidCallback callback) {
    return new MaterialButton(
      child: Text(
        title,
        style: new TextStyle(
          color: Colors.white,
        ),
      ),
      color: Colors.blueAccent,
      onPressed: () async {
        callback();
        dismissTimer?.cancel();
        dismissTimer = new Timer(new Duration(seconds: 5), () async {
          if (await Progresshud.isVisible()) {
            await Progresshud.dismiss();
            print('dismiss');
          } else {
            print('..');
          }
        });
      },
    );
  }
}
2
likes
0
pub points
20%
popularity

Publisher

unverified uploader

A useful Hud framework is implemented by calling native code by Flutter. With one line of code, you can call Hud out anywhere and control its hiding. In the example App, you can see how to use it. SVProgress HUD is used on iOS and SVProgress HUD-Android is used on Android (this package is a copy of iOS version). UI comes from the native layer, so there is not too much definition space. If you need to customize, you can rewrite the framework code on each platform separately (more troublesome).

Repository (GitHub)
View/report issues

Dependencies

flutter

More

Packages that depend on ovprogresshud