2022-09-27 15:43:52 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomRadio extends StatelessWidget {
|
2022-10-19 14:12:53 +02:00
|
|
|
final dynamic value;
|
|
|
|
final dynamic groupValue;
|
|
|
|
final Function(dynamic)? onChange;
|
2022-09-27 15:43:52 +02:00
|
|
|
final Color backgroundColor;
|
|
|
|
|
|
|
|
const CustomRadio({
|
2024-09-11 18:13:26 +02:00
|
|
|
super.key,
|
2022-09-27 15:43:52 +02:00
|
|
|
required this.value,
|
|
|
|
required this.groupValue,
|
|
|
|
this.onChange,
|
|
|
|
required this.backgroundColor,
|
2024-09-11 18:13:26 +02:00
|
|
|
});
|
2022-09-27 15:43:52 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Stack(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
2022-10-19 14:12:53 +02:00
|
|
|
width: 18,
|
|
|
|
height: 18,
|
2022-09-27 15:43:52 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(40),
|
|
|
|
color: value == groupValue
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
2022-09-27 15:43:52 +02:00
|
|
|
: Theme.of(context).brightness == Brightness.dark
|
|
|
|
? const Color.fromRGBO(184, 184, 184, 1)
|
|
|
|
: const Color.fromRGBO(104, 104, 104, 1)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
2022-10-19 14:12:53 +02:00
|
|
|
width: 14,
|
|
|
|
height: 14,
|
2022-09-27 15:43:52 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(35),
|
|
|
|
color: backgroundColor
|
|
|
|
),
|
|
|
|
),
|
2022-10-19 14:12:53 +02:00
|
|
|
AnimatedContainer(
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
width: 9.5,
|
|
|
|
height: 9.5,
|
2022-09-27 15:43:52 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
|
|
|
color: value == groupValue
|
2023-01-25 20:51:23 +01:00
|
|
|
? Theme.of(context).colorScheme.primary
|
2022-09-27 15:43:52 +02:00
|
|
|
: backgroundColor
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|