26 lines
777 B
Dart
26 lines
777 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, // 默认底部显示
|
||
|
}) {
|
||
|
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(milliseconds: 5000),
|
||
|
style: baseStyle?.copyWith(
|
||
|
backgroundColor: type == 'success' ? Colors.green.withAlpha(200) : Colors.red.withAlpha(200),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|