Encrypted messaging app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

  1. import 'package:flutter/material.dart';
  2. class FlashMessage extends StatelessWidget {
  3. const FlashMessage({
  4. Key? key,
  5. required this.message,
  6. }) : super(key: key);
  7. final String message;
  8. @override
  9. Widget build(BuildContext context) {
  10. final theme = Theme.of(context);
  11. return Stack(
  12. clipBehavior: Clip.none,
  13. children: <Widget>[
  14. Container(
  15. padding: const EdgeInsets.all(16),
  16. height: 90,
  17. decoration: BoxDecoration(
  18. borderRadius: const BorderRadius.all(Radius.circular(20)),
  19. color: theme.colorScheme.onError,
  20. ),
  21. child: Column(
  22. children: <Widget>[
  23. Text(
  24. 'Error',
  25. style: TextStyle(
  26. color: theme.colorScheme.error,
  27. fontSize: 18
  28. ),
  29. ),
  30. Text(
  31. message,
  32. style: TextStyle(
  33. color: theme.colorScheme.error,
  34. fontSize: 14
  35. ),
  36. ),
  37. ],
  38. ),
  39. ),
  40. ]
  41. );
  42. }
  43. }
  44. void showMessage(String message, BuildContext context) {
  45. ScaffoldMessenger.of(context).showSnackBar(
  46. SnackBar(
  47. content: FlashMessage(
  48. message: message,
  49. ),
  50. behavior: SnackBarBehavior.floating,
  51. backgroundColor: Colors.transparent,
  52. elevation: 0,
  53. ),
  54. );
  55. }