dilemmaMaterial<T> static method
Future<T?>
dilemmaMaterial<T>(
- BuildContext context, {
- required String title,
- required String content,
- String rightButton = "ACCEPT",
- String leftButton = "CANCEL",
- bool centerContent = false,
- bool? dark,
- VoidCallback? onTapedRight,
- VoidCallback? onTapedLeft,
Implementation
static Future<T?> dilemmaMaterial<T>(
BuildContext context, {
required String title,
required String content,
String rightButton = "ACCEPT",
String leftButton = "CANCEL",
bool centerContent = false,
bool? dark,
VoidCallback? onTapedRight,
VoidCallback? onTapedLeft,
}) {
bool _dark = dark ?? (Theme.of(context).brightness == Brightness.dark);
Color _fontColor = _dark ? Colors.white : Colors.black;
TextStyle getTextStyle(Set<MaterialState> states) {
const Set<MaterialState> interactiveStates = <MaterialState>{
MaterialState.pressed,
MaterialState.hovered,
MaterialState.focused,
};
if (states.any(interactiveStates.contains)) {
return TextStyle(color: Color(0xFF6200EE));
}
return TextStyle(color: _fontColor);
}
return showDialog<T>(
context: context,
builder: (context) {
return AlertDialog(
title: Text(title),
content: Text(content),
actions: [
TextButton(
onPressed: onTapedLeft,
child: Text(leftButton),
// style: ButtonStyle(
// textStyle: MaterialStateProperty.resolveWith((states) => getTextStyle(states)),
// backgroundColor: MaterialStateProperty.resolveWith((states) => getTextStyle(states).color),
// ),
// style: TextButton.styleFrom(primary: Color(0xff000f0f)),
),
TextButton(
onPressed: onTapedRight,
child: Text(
rightButton,
style: Theme.of(context)
.textTheme
.subtitle1!
.copyWith(color: Colors.orangeAccent),
),
// style: ButtonStyle(
// textStyle: MaterialStateProperty.resolveWith((states) => getTextStyle(states)),
// ),
)
],
);
},
);
}