image_button.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. class ImageButton extends StatelessWidget{
  3. final VoidCallback onPressed;
  4. final String? title;
  5. final Widget image;
  6. const ImageButton({
  7. super.key,
  8. required this.onPressed,
  9. required this.image,
  10. this.title,
  11. });
  12. @override
  13. Widget build(BuildContext context) {
  14. var children = <Widget>[
  15. image,
  16. ];
  17. if (title != null){
  18. children.add(const SizedBox(height: 2));
  19. children.add(Text(title!));
  20. }
  21. return TextButton(
  22. onPressed: onPressed,
  23. style: TextButton.styleFrom(
  24. minimumSize: Size.zero,
  25. padding: const EdgeInsets.all(5),
  26. textStyle: const TextStyle(
  27. color: Color(0xff818181),
  28. fontSize: 10,
  29. ),
  30. backgroundColor: Colors.transparent,
  31. foregroundColor: const Color(0xff818181),
  32. shape:RoundedRectangleBorder(
  33. borderRadius: BorderRadius.circular(0),
  34. ),
  35. ),
  36. child: Column( // Replace with a Row for horizontal icon + text
  37. children: children,
  38. )
  39. );
  40. }
  41. }