34 lines
955 B
Dart
34 lines
955 B
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../../helpers/theme.dart';
|
||
|
|
|
||
|
|
class LocalRadio<T> extends StatelessWidget {
|
||
|
|
final Function(T?)? onChanged;
|
||
|
|
final T value;
|
||
|
|
final T? groupValue;
|
||
|
|
|
||
|
|
const LocalRadio(
|
||
|
|
{super.key, this.onChanged, required this.value, this.groupValue});
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Radio<T>(
|
||
|
|
fillColor: MaterialStateProperty.resolveWith((states) {
|
||
|
|
// active
|
||
|
|
if (states.contains(MaterialState.selected)) {
|
||
|
|
return primaryColor;
|
||
|
|
}
|
||
|
|
// inactive
|
||
|
|
return labelColor;
|
||
|
|
}),
|
||
|
|
visualDensity: const VisualDensity(
|
||
|
|
horizontal: VisualDensity.minimumDensity,
|
||
|
|
vertical: VisualDensity.minimumDensity),
|
||
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||
|
|
activeColor: primaryColor,
|
||
|
|
groupValue: groupValue,
|
||
|
|
value: value,
|
||
|
|
onChanged: onChanged);
|
||
|
|
}
|
||
|
|
}
|