2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00
inventree-app/lib/widget/snacks.dart
2021-02-11 00:02:00 +11:00

36 lines
788 B
Dart

/*
* Display a snackbar with:
*
* a) Text on the left
* b) Icon on the right
*
* | Text <icon> |
*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
void showSnackIcon(GlobalKey<ScaffoldState> key, String text, {IconData icon, bool success}) {
// Hide the current snackbar
key.currentState.hideCurrentSnackBar();
// If icon not specified, use the success status
if (icon == null) {
icon = (success == true) ? FontAwesomeIcons.checkCircle : FontAwesomeIcons.timesCircle;
}
key.currentState.showSnackBar(
SnackBar(
content: Row(
children: [
Text(text),
Spacer(),
FaIcon(icon)
]
),
)
);
}