我有一个Radio
,我想在一个条件下禁用它,比如:
if (enabled == true){
*enable radio button*
} else {
*disable radio button*
}
编辑
我将添加类的完整代码,因为我只添加了其中的一部分.
以下是完整的代码:
import 'package:flutter/material.dart';
class RadioButton extends StatelessWidget {
final String label;
final int groupValue;
final int value;
final ValueChanged<int> onChanged;
const RadioButton(
{super.key,
required this.label,
required this.groupValue,
required this.value,
required this.onChanged});
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Radio<int>(
groupValue: groupValue,
value: value,
onChanged: (int? newValue) {
onChanged(newValue!);
}),
),
Text(label),
],
),
),
],
),
],
);
}
}