Is it possible to create duration timer, like in iOS in flutter?
example
just use format() method to get AM,PM what you required.
DatePicker and Timer Picker is a material widget in a flutter that lets the user select a date and time. Since there is no widget available for creating a date picker and time picker we will use showDatePicker() function and showTimePicker() Function.
For example a custom format " ddddd, MMMM dd, yyyy hh:mm:ss tt " will give you a result like this : "Thursday, August 20, 2009 02:55:23 PM". "DateTime Picker can be used to pick both date and time that is why it is called 'Date and Time Picker'." - except that it can't, which is why the question was asked.
What you can do is create 2 variables one for start time and one for end time. TimeOfDay _startTime; TimeOfDay _endTime; Then make your _buildTimePick function a little more flexible by passing the time to display.
There is a CupertinoTimePicker widget that does just this
Check this out
class Cupert extends StatefulWidget {
@override
_CupertState createState() => _CupertState();
}
class _CupertState extends State<Cupert> {
var value = "";
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
children: <Widget>[
Expanded(
child: Center(
child: Text(
"$value"
),
),
),
CupertinoTimerPicker(
mode: CupertinoTimerPickerMode.hm,
onTimerDurationChanged: (value){
setState(() {
this.value = value.toString();
});
},
),
],
),
),
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With