I managed to create a function (which I put in a TextButton) where you can see the Time_range_picker and choose the range.
I just can't show the result either in a text widget or in the button label.
class OpeningHours extends StatefulWidget {
const OpeningHours({Key? key}) : super(key: key);
@override
State<OpeningHours> createState() => _OpeningHoursState();
}
class _OpeningHoursState extends State<OpeningHours> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton.icon(
icon: const Icon(
FontAwesomeIcons.penToSquare,
color: Colors.white,
),
label: Text(
result.toString(), // it does not work
style: const TextStyle(
color: Colors.white,
fontSize: 22,
),
),
style: TextButton.styleFrom(
shadowColor: Colors.red,
elevation: 18,
backgroundColor: Colors.red),
onPressed: () {
pickTimeRange(context);
},
),
),
);
}
Future pickTimeRange(BuildContext context) async {
final TimeRange? result = await showTimeRangePicker(context: context);
}
}