27 lines
818 B
Dart
27 lines
818 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shirne_dialog/shirne_dialog.dart';
|
|
|
|
class MyToast {
|
|
///
|
|
void tip({
|
|
required String title,
|
|
String? type, // 默认失败
|
|
String? position, // 默认底部显示
|
|
Duration? duration
|
|
}) {
|
|
final baseStyle = position == 'top'
|
|
? MyDialog.theme.toastStyle?.top()
|
|
: position == 'center'
|
|
? MyDialog.theme.toastStyle?.center()
|
|
: MyDialog.theme.toastStyle?.bottom();
|
|
MyDialog.toast(
|
|
title,
|
|
icon: type == 'success' ? const Icon(Icons.check_circle) : Icon(Icons.warning),
|
|
duration: duration ?? const Duration(milliseconds: 5000),
|
|
style: baseStyle?.copyWith(
|
|
backgroundColor: type == 'success' ? Colors.green.withAlpha(200) : Colors.red.withAlpha(200),
|
|
),
|
|
);
|
|
}
|
|
}
|