Line data Source code
1 : import 'package:flutter/material.dart'; 2 : import 'package:pal/src/theme.dart'; 3 : 4 : class SnackbarMixin { 5 2 : showSnackbarMessage( 6 : GlobalKey<ScaffoldState> _scaffoldKey, String message, bool success) { 7 2 : if (_scaffoldKey?.currentContext == null) { 8 : return; 9 : } 10 4 : _scaffoldKey.currentState.showSnackBar( 11 2 : SnackBar( 12 2 : content: Row( 13 2 : children: <Widget>[ 14 : success 15 2 : ? Icon(Icons.check, color: Colors.lightGreenAccent) 16 0 : : Icon(Icons.warning, color: PalTheme.of(_scaffoldKey.currentContext).colors.light), 17 2 : Flexible( 18 2 : child: Padding( 19 : padding: const EdgeInsets.only(left: 8.0), 20 2 : child: Text( 21 : message, 22 : maxLines: 2, 23 : overflow: TextOverflow.ellipsis, 24 : ), 25 : ), 26 : ), 27 : ], 28 : ), 29 8 : backgroundColor: success ? PalTheme.of(_scaffoldKey.currentContext).colors.dark : Colors.redAccent, 30 2 : duration: Duration(milliseconds: 1500), 31 : ), 32 : ); 33 : } 34 : }