createCustomToast function
void
createCustomToast()
Implementation
void createCustomToast() {
final coreDir = DirsRepository.coreDir();
createFile('${coreDir.path}/widgets', 'custom_toast.dart', '''
/// if you haven't added the fluttertoast package to
/// your pubspec.yaml file yet. please add it by
/// running `flutter pub add fluttertoast` in
/// your terminal( cmd )
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class CustomToast {
static showSuccessToast({String message = "success"}) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 16.0);
}
static showErrorToast({String message = "Error Occurred."}) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0);
}
static showInfo({String message = ""}) {
Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.grey,
textColor: Colors.white,
fontSize: 16.0);
}
}
''');
}