showText function
Information dialog Shows a flash dialog or a simple dialog with @isFlash = false
Implementation
Future<bool> showText(
BuildContext context,
String title,
String subtitle, {
bool isNotification = false,
bool isFlash = true,
int seconds = 5,
Color? backgroundColor,
Widget? leading,
Widget? titleMessage,
Widget? subtitleMessage,
Widget? closeTextDialog,
List<Widget>? trailing,
Function? onTap,
}) async {
try {
if (isFlash) {
return (await showFlash(
context: context,
duration: Duration(seconds: seconds),
transitionDuration: Duration(seconds: isNotification ? 2 : 1),
builder: (context, controller) {
return Flash(
forwardAnimationCurve: Curves.elasticInOut,
reverseAnimationCurve: Curves.elasticInOut,
controller: controller,
position: FlashPosition.bottom,
child: GestureDetector(
onTap: () {
if (onTap != null) onTap();
},
child: FlashBar(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(!isNotification ? 0 : 20))),
margin: !isNotification
? EdgeInsets.zero
: const EdgeInsets.all(20),
shouldIconPulse: false,
icon: SizedBox(height: 30, width: 30, child: leading),
actions: trailing,
backgroundColor: backgroundColor ?? Colors.blue[800],
title: titleMessage ??
Text(
title,
style: const TextStyle(
color: Colors.white, fontSize: 20),
),
content: subtitleMessage ??
Text(
subtitle,
style: const TextStyle(
color: Colors.white70, fontSize: 16),
),
controller: controller,
),
),
);
},
) as bool?) ??
false;
} else {
return await showDialog<bool>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return SimpleDialog(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20))),
children: <Widget>[
Padding(
padding: const EdgeInsets.all(20.0),
child: titleMessage ??
Text(
title,
style: TextStyle(
color: Colors.green[900], fontSize: 25),
),
),
Padding(
padding: const EdgeInsets.all(15.0),
child: subtitleMessage ??
Text(
subtitle,
style: TextStyle(
color: Colors.brown[900], fontSize: 15),
),
),
Padding(
padding: const EdgeInsets.all(30.0),
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: closeTextDialog ??
const Text(
"OK",
style: TextStyle(
color: Colors.white, fontSize: 18),
),
),
),
),
],
);
}) ??
false;
}
} catch (err) {
if (kDebugMode) {
print(err);
}
return false;
}
}