2022-06-28 10:32:16 -04:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
/// A simple widget that displays an alert message in the center.
|
|
|
|
|
class AlertMessage extends StatelessWidget {
|
|
|
|
|
final String message;
|
2022-07-28 21:44:28 -04:00
|
|
|
final Color? color;
|
2023-10-22 18:38:32 -04:00
|
|
|
final bool centered;
|
2022-06-28 10:32:16 -04:00
|
|
|
|
|
|
|
|
const AlertMessage({
|
2023-10-28 18:13:23 -04:00
|
|
|
super.key,
|
2022-06-28 10:32:16 -04:00
|
|
|
required this.message,
|
2023-10-22 18:38:32 -04:00
|
|
|
this.centered = true,
|
2022-07-28 21:44:28 -04:00
|
|
|
this.color,
|
2023-10-28 18:13:23 -04:00
|
|
|
});
|
2022-06-28 10:32:16 -04:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2024-09-06 21:43:27 -07:00
|
|
|
final defaultColor =
|
|
|
|
|
Theme.of(context).colorScheme.onSurface.withOpacity(0.5);
|
|
|
|
|
|
2022-06-28 10:32:16 -04:00
|
|
|
return Row(
|
2023-10-22 18:38:32 -04:00
|
|
|
mainAxisAlignment:
|
|
|
|
|
centered ? MainAxisAlignment.center : MainAxisAlignment.start,
|
2022-06-28 10:32:16 -04:00
|
|
|
children: [
|
|
|
|
|
Icon(
|
2023-01-18 05:34:54 -05:00
|
|
|
Icons.info_outline_rounded,
|
2024-09-06 21:43:27 -07:00
|
|
|
color: color ?? defaultColor,
|
2022-06-28 10:32:16 -04:00
|
|
|
),
|
2023-10-22 18:38:32 -04:00
|
|
|
const SizedBox(width: 8),
|
2022-07-05 04:57:47 -04:00
|
|
|
Flexible(
|
|
|
|
|
child: Text(
|
|
|
|
|
message,
|
2022-07-28 21:44:28 -04:00
|
|
|
style: TextStyle(
|
2024-09-06 21:43:27 -07:00
|
|
|
color: color ?? defaultColor,
|
2022-07-05 04:57:47 -04:00
|
|
|
),
|
2022-06-28 10:32:16 -04:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|