45 lines
976 B
Dart
45 lines
976 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SnackBarService {
|
|
//
|
|
|
|
BuildContext? _buildContext;
|
|
static SnackBarService instance = SnackBarService();
|
|
|
|
set buildContext(BuildContext _context) {
|
|
_buildContext = _context;
|
|
}
|
|
|
|
void showSnackBarError(String _message) {
|
|
ScaffoldMessenger.of(_buildContext!).showSnackBar(
|
|
SnackBar(
|
|
duration: Duration(seconds: 2),
|
|
content: Text(
|
|
_message,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
backgroundColor: Colors.red,
|
|
),
|
|
);
|
|
}
|
|
|
|
void showSnackBarSuccess(String _message) {
|
|
ScaffoldMessenger.of(_buildContext!).showSnackBar(
|
|
SnackBar(
|
|
duration: Duration(seconds: 2),
|
|
content: Text(
|
|
_message,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
backgroundColor: Colors.green,
|
|
),
|
|
);
|
|
}
|
|
}
|