tip_dialog 1.0.1 tip_dialog: ^1.0.1 copied to clipboard
A Flutter Tip Dialog
TipDialog #
A Flutter Tip Dialog
Loading Type Dialog | Success Tye Dialog | Fail Type Dialog |
---|---|---|
Info Type Dialog | Only Icon Dialog | Onl Text Dialog |
---|---|---|
Custom Icon Dialog | Custom Body Dialog |
---|---|
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 tip,
TipDialogType type: 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
final GlobalKey<TipDialogContainerState> _tipDialogKey = new GlobalKey();
Widget _buildItem(String name, VoidCallback callback) {
return new GestureDetector(
onTap: callback,
child: new ListTile(
title: new Text(name),
),
);
}
new TipDialogContainer(
key: _tipDialogKey,
type: TipDialogType.LOADING,
tip: "Loading",
child: new ListView(children: <Widget>[
_buildItem("Loading Type Tip Dialog", () async {
_tipDialogKey.currentState.show();
await new Future.delayed(new Duration(seconds: 3));
_tipDialogKey.currentState.dismiss();
}),
new Divider(),
]),
)
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 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.