Created
March 5, 2020 10:04
-
-
Save xinthink/55d100dbcce13b11a025701218b3caf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin CommandHandler<T extends StatefulWidget> on State<T> { | |
/// Processes the given [command]. | |
Future<void> processNoteCommand(ScaffoldState scaffoldState, NoteCommand command) async { | |
if (command == null) { | |
return; | |
} | |
await command.execute(); | |
final msg = command.message; | |
if (mounted && msg?.isNotEmpty == true) { | |
scaffoldState?.showSnackBar(SnackBar( | |
content: Text(msg), | |
action: SnackBarAction( | |
label: 'Undo', | |
onPressed: () => command.revert(), | |
), | |
)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment