tip_dialog 1.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 83

TipDialog

A Flutter Tip Dialog

Loading Type DialogSuccess Tye DialogFail Type Dialog
WechatIMG9WechatIMG8WechatIMG6
Info Type DialogOnly Icon DialogOnl Text Dialog
WechatIMG7WechatIMG5WechatIMG4
Custom Icon DialogCustom Body Dialog
WechatIMG3WechatIMG2

Rendering

1. Depend on it

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

dependencies:
  tip_dialog: ^1.0.0

2. Install it

You can install packages from the command line: with Flutter:

$ flutter packages get

3. Import it

Now in your Dart code, you can use:

import 'package:loading_view/loading_view.dart';

4. Use

Available attributes

[ TipDialogContainer ]
@required this.child,
String defaultTip,
TipDialogType defaultType: TipDialogType.NOTHING,
/// automatically disappear time
this.duration: const Duration(seconds: 3),
/// In the beginning, whether to display 
this.show: false,
/// whether show mask layer
this.outSideTouchable: false,
/// mask layer alpha
this.maskAlpha: 0.3

Global Use

/// Use [TipDialogContainer] globally
/// This widget can be globally supported
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new TipDialogContainer(
        defaultType: TipDialogType.LOADING,
        defaultTip: "Loading",
        child: new MaterialApp(
          title: 'TipDialog Demo',
          theme: new ThemeData(),
          home: new MyHomePage(title: 'TipDialog Demo Home Page'),
        ));
  }
}

/// Use [TipDialogConnector] to obtain [TipDialogController]
/// In addition to using controller, you can also use [GlobalKey] to control show or dismiss
new TipDialogConnector(
  builder: (context, tipController) {
    return new ListView(children: <Widget>[
      _buildItem("Loading Type Tip Dialog", () async {
        tipController.show();
        await new Future.delayed(new Duration(seconds: 3));
        tipController.dismiss();
      }),
      new Divider(),
      _buildItem("Success Type Tip Dialog", () async {
        tipController.show(
        tipDialog: new TipDialog(
          type: TipDialogType.SUCCESS,
          tip: "Loaded Successfully",
        ));
      }),
    ]);
  },
)

Use a custom widget when using [TipDialogContainer] globally, there may be appear some unexpected errors. such as Text or Icon, will appear similar to the following error.

No Directionality widget found.

Just set TextDirection just fine. See the custom Widget in the example for details.

5. Default Dialog Type

enum TipDialogType { NOTHING, LOADING, SUCCESS, FAIL, INFO }

NONTHING: no icon
LOADING: have a loading icon
SUCCESS: have a success icon
FAIL: have a fail icon
INFO: have a info icon

6. State And TipDialogController Method

/// tipDialog: Need to display the widget
/// (default uses the dialog set by [TipDialogContainer])
///
/// isLoading: decide whether to disappear automatically
/// (default uses the value set by [TipDialogContainer],
/// set type = TipDialogType.LOADING, the value will be true, otherwise will be false.)
/// if true, the dialog will not automatically disappear
/// otherwise, the dialog will automatically disappear after the [Duration] set by [TipDialogContainer]
void show({Widget tipDialog, bool isLoading: false});

/// dismiss dialog
void dismiss();

See the example directory for more details.

[1.0.0] - first release.

  • add release.

[1.0.1] - (MODIFY).

  • fix loading view version bug.
  • set default loading duration

[1.1.0] - (FUNCTION CHANGE)

  • add tip dialog global support

[1.1.1] - (MODIFY)

  • fix bugs that occur when using globally

example/lib/main.dart

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new TipDialogContainer(
        defaultType: TipDialogType.LOADING,
        defaultTip: "Loading",
        child: new MaterialApp(
          title: 'TipDialog Demo',
          theme: new ThemeData(),
          home: new MyHomePage(title: 'TipDialog Demo Home Page'),
        ));
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  Widget _buildItem(String name, VoidCallback callback) {
    return new GestureDetector(
      onTap: callback,
      child: new ListTile(
        title: new Text(name),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
        elevation: 0.5,
      ),
      body: new TipDialogConnector(
        builder: (context, tipController) {
          return new ListView(children: <Widget>[
            _buildItem("Loading Type Tip Dialog", () async {
              tipController.show();
              await new Future.delayed(new Duration(seconds: 3));
              tipController.dismiss();
            }),
            new Divider(),
            _buildItem("Success Type Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog(
                type: TipDialogType.SUCCESS,
                tip: "Loaded Successfully",
              ));
            }),
            new Divider(),
            _buildItem("Fail Type Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog(
                type: TipDialogType.FAIL,
                tip: "Load Failed ",
              ));
            }),
            new Divider(),
            _buildItem("Info Type Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog(
                type: TipDialogType.INFO,
                tip: "Do Not Repeat",
              ));
            }),
            new Divider(),
            _buildItem("Only Icon Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog(
                type: TipDialogType.SUCCESS,
              ));
            }),
            new Divider(),
            _buildItem("Only text Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog(
                type: TipDialogType.NOTHING,
                tip: "Do Not Repeat",
              ));
            }),
            new Divider(),
            _buildItem("Custom Icon Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog.customIcon(
                icon: new Icon(
                  Icons.file_download,
                  color: Colors.white,
                  size: 30.0,
                  textDirection: TextDirection.ltr,
                ),
                tip: "Download",
              ));
            }),
            new Divider(),
            _buildItem("Custom Body Tip Dialog", () async {
              tipController.show(
                  tipDialog: new TipDialog.builder(
                bodyBuilder: (context) {
                  return new Container(
                    width: 120.0,
                    height: 90.0,
                    alignment: Alignment.center,
                    child: new Text(
                      "Custom",
                      style: new TextStyle(color: Colors.white),
                      /// if TipDialogContainer are outside of MaterialApp,
                      /// here is a must to set
                      textDirection: TextDirection.ltr,
                    ),
                  );
                },
                color: Colors.blue.withAlpha(150),
              ));
            }),
            new Divider(),
          ]);
        },
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  tip_dialog: ^1.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tip_dialog/tip_dialog.dart';
  
Version Uploaded Documentation Archive
1.1.1 Sep 1, 2018 Go to the documentation of tip_dialog 1.1.1 Download tip_dialog 1.1.1 archive
1.1.0 Sep 1, 2018 Go to the documentation of tip_dialog 1.1.0 Download tip_dialog 1.1.0 archive
1.0.1 Aug 17, 2018 Go to the documentation of tip_dialog 1.0.1 Download tip_dialog 1.0.1 archive
1.0.0 Aug 17, 2018 Go to the documentation of tip_dialog 1.0.0 Download tip_dialog 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
74
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
83
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
loading_view ^1.0.2 1.0.2
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test