flutter_icon_snackbar

这个小部件是 Flutter 中一个简单的 snackbar,包含动画和图标。

Flutter

特点

安装

dependencies:
  flutter_icon_snackbar: ^<latest_version>

? 用法

1. 常见用法

icon_snackbar 的默认类型。

IconSnackBar.show(
    context: context, 
    snackBarType: SnackBarType.save, 
    label: 'Save successfully'
);

2. snackbar 类型

Snackbar 有多种类型,您可以设置保存、失败和警告的类型。图标包含动画,图标在此,您可以使用的。

IconSnackBar.show(context: context, snackBarType: SnackBarType.error, label: 'Save failed!');
IconSnackBar.show(context: context, snackBarType: SnackBarType.alert, label: 'Data required');

3. 自定义主题

还可以修改 Snackbar 的主题。主题包含以下数据。

class SnackBarStyle {
  final Color? backgroundColor;
  final Color iconColor;
  final TextStyle labelTextStyle;
  final bool showIconFirst;

  const SnackBarStyle({this.backgroundColor, this.iconColor = Colors.white, this.labelTextStyle = const TextStyle(), this.showIconFirst = false});
}

4. 另一个动画

动画包含更多内容。

IconSnackBar.show(
    context: context, 
    snackBarType: SnackBarType.alert, 
    label: 'Data required', 
    snackBarStyle: const SnackBarStyle(showIconFirst: true) // this one
);

GitHub

查看 Github