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.

55 lines
1.6 KiB

2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. class PickImageButton extends ConsumerWidget {
  4. const PickImageButton({
  5. Key? key,
  6. required this.text,
  7. required this.onTap,
  8. this.padding = const EdgeInsets.only(top: 13.0, bottom: 12.0),
  9. this.width = 145,
  10. }) : super(key: key);
  11. final String text;
  12. final Function()? onTap;
  13. final EdgeInsets padding;
  14. final double width;
  15. @override
  16. Widget build(BuildContext context, WidgetRef ref) {
  17. return SizedBox(
  18. width: width,
  19. child: ElevatedButton(
  20. style: ButtonStyle(
  21. shape: MaterialStateProperty.all<RoundedRectangleBorder>(
  22. RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
  23. ),
  24. backgroundColor: MaterialStateProperty.resolveWith<Color>(
  25. (Set<MaterialState> states) {
  26. if (states.contains(MaterialState.pressed)) {
  27. return Theme.of(context).colorScheme.primary.withOpacity(0.5);
  28. } else if (states.contains(MaterialState.disabled)) {
  29. return Theme.of(context).colorScheme.primary.withOpacity(0.5);
  30. }
  31. return Theme.of(context)
  32. .colorScheme
  33. .primary; // Use the component's default.
  34. },
  35. ),
  36. ),
  37. onPressed: onTap,
  38. child: Padding(
  39. padding: padding,
  40. child: Text(
  41. text,
  42. style: TextStyle(
  43. fontSize: 16,
  44. color: Colors.white.withOpacity(onTap == null ? 0.6 : 1),
  45. ),
  46. ),
  47. ),
  48. ),
  49. );
  50. }
  51. }