var _oneValue = '';
var timeSlot = [
"١٢:٠٠ منتصف الليل",
"١:٠٠ صباحا",......
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Expanded(
child: Text(
(timeSlot[i]),
style: Typographies
.largeBodyStyle(),
),
),
Radio(
activeColor:
ColorManager
.black,
value: timeSlot[i],
groupValue:
_oneValue,
onChanged:
(value) {
setState(
() {
_oneValue =
value!;
print(
_oneValue);
});
})
],
),
UPDATED:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({super.key});
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
List timeSlot = [
{'label': 'Item1', 'value': 1},
{'label': 'Item2', 'value': 2}
];
int _oneValue = -1;
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
for (var item in timeSlot)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
(item['label']),
// style: Typographies.largeBodyStyle(),
),
),
Radio(
activeColor: Colors.blue,
value: item['value'],
groupValue: _oneValue,
onChanged: (value) {
setState(() {
_oneValue = value!;
print(_oneValue);
});
})
],
),
],
);
}
}