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.

53 lines
1.6 KiB

2 years ago
2 years ago
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).colorScheme.primary;
  32. },
  33. ),
  34. ),
  35. onPressed: onTap,
  36. child: Padding(
  37. padding: padding,
  38. child: Text(
  39. text,
  40. style: TextStyle(
  41. fontSize: 16,
  42. color: Colors.white.withOpacity(onTap == null ? 0.6 : 1),
  43. ),
  44. ),
  45. ),
  46. ),
  47. );
  48. }
  49. }