Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:grouped_buttons/grouped_buttons.dart';
- class SelectCard extends StatelessWidget {
- final FormFieldValidator<String> validator;
- final void Function(String) onSelect;
- final List<String> options;
- final String selected;
- const SelectCard({
- Key key,
- @required this.options,
- @required this.onSelect,
- @required this.selected,
- this.validator,
- }) : assert(options != null),
- assert(selected != null),
- super(key: key);
- @override
- Widget build(BuildContext context) {
- return Card(
- child: FormField(
- initialValue: selected,
- validator: validator,
- builder: (FormFieldState<String> state) => Column(
- children: <Widget>[
- RadioButtonGroup(
- picked: selected,
- labels: options,
- onSelected: (String selected) {
- onSelect(selected);
- state.didChange(selected);
- },
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: state.hasError
- ? Padding(
- padding: const EdgeInsets.symmetric(
- vertical: UiSettings.padding,
- horizontal: 30,
- ),
- child: Text(
- state.errorText,
- style: Theme.of(context).textTheme.body1.copyWith(
- color: KColors.error,
- fontSize: 12.0,
- ),
- ),
- )
- : Container(),
- )
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement