0

How can I call to action in flutter dateTime picker? I have got working state that updates current time to selected time but I am not sure how to execute selected time to do something.(if _time = current Time.now => Do something")Any help will be much appreciated.Do I need to implement counter or update timer every minute first?

String _time = "Set Timer";

        Padding(
          padding: const EdgeInsets.all(35.0),
          child: Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[

              // const SizedBox(
              //   height: 10.0,
              // ),
              
              ElevatedButton(
                onPressed: () {
                  DatePicker.showTimePicker(context,
                      theme: const DatePickerTheme(
                        containerHeight: 210.0,
                      ),
                      showTitleActions: true,
                      onConfirm: (time) {
                        _time =
                        '${time.hour} : ${time.minute}';
                        setState(() {});
                       
                      },
                      currentTime: DateTime.now(),
                      locale: LocaleType.en);
                  setState(() {});

                },
                  style: ElevatedButton.styleFrom(
                  backgroundColor: Color.fromARGB(121, 126, 239, 234),
                  padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
                  shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(10.0)),
                  textStyle: const TextStyle(
                  fontSize: 22,)),

                  

                  //Visual Look of Timer Displayed

                      child: Container(
                        alignment: Alignment.center,
                        height: 30.0,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: <Widget>[
                            Row(
                              children: <Widget>[
                                Row(
                                  children: <Widget>[
                                    const Icon(
                                      Icons.access_time,
                                      size: 18.0,
                                      color: Color.fromARGB(255, 255, 255, 255),
                                    ),
                                    Text(
                                      " $_time",
                                      style: const TextStyle(
                                          color: Color.fromARGB(255, 255, 255, 255),
                                          fontSize: 18.0),
                                    ),
                                  ],
                                )
                              ],
                            ),
                            const Text(
                              "  Change",
                              style: TextStyle(
                                  color: Color.fromARGB(255, 255, 255, 255),
                                  fontWeight: FontWeight.bold,
                                  fontSize: 18.0),
                            ),
                          ],
                        ),
                      ),
                    
                    )
                  ],
                ),
              ), 
Jacob Nero
  • 1
  • 1
  • 2

0 Answers0