Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create timer picker in flutter?

Is it possible to create duration timer, like in iOS in flutter?

example duration picker

like image 587
Tree Avatar asked Feb 11 '18 19:02

Tree


People also ask

How do you add AM and PM in time picker in Flutter?

just use format() method to get AM,PM what you required.

How do you select date and time in Flutter?

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.

How do you pick date and time?

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.

How do I set start time and end time in Flutter?

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.


1 Answers

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();
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}
like image 155
Josteve Avatar answered Oct 20 '22 23:10

Josteve