Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:grouped_buttons/grouped_buttons.dart';
  3.  
  4. class SelectCard extends StatelessWidget {
  5. final FormFieldValidator<String> validator;
  6. final void Function(String) onSelect;
  7. final List<String> options;
  8. final String selected;
  9.  
  10. const SelectCard({
  11. Key key,
  12. @required this.options,
  13. @required this.onSelect,
  14. @required this.selected,
  15. this.validator,
  16. }) : assert(options != null),
  17. assert(selected != null),
  18. super(key: key);
  19.  
  20. @override
  21. Widget build(BuildContext context) {
  22. return Card(
  23. child: FormField(
  24. initialValue: selected,
  25. validator: validator,
  26. builder: (FormFieldState<String> state) => Column(
  27. children: <Widget>[
  28. RadioButtonGroup(
  29. picked: selected,
  30. labels: options,
  31. onSelected: (String selected) {
  32. onSelect(selected);
  33. state.didChange(selected);
  34. },
  35. ),
  36. Align(
  37. alignment: Alignment.centerLeft,
  38. child: state.hasError
  39. ? Padding(
  40. padding: const EdgeInsets.symmetric(
  41. vertical: UiSettings.padding,
  42. horizontal: 30,
  43. ),
  44. child: Text(
  45. state.errorText,
  46. style: Theme.of(context).textTheme.body1.copyWith(
  47. color: KColors.error,
  48. fontSize: 12.0,
  49. ),
  50. ),
  51. )
  52. : Container(),
  53. )
  54. ],
  55. ),
  56. ),
  57. );
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement