How do i make a countdown timer in flutter

时间:2019-06-01 14:06:16

标签: datetime flutter timer countdowntimer timeofday

I am trying to make a countdown timer in flutter with seconds minutes hours days and weeks and i dont know how do i subtract the time i picked from the current time and use the date for the days and the weeks (im new in flutter)

I already did the timeofday picker and datetime picker

   Future<void> _selectDate(BuildContext context) async {
     final DateTime picked = await showDatePicker(
         context: context ,
         initialDate: _date,
         firstDate: new DateTime(2010),
         lastDate: new DateTime(2120)
     );
     if(picked != null && picked != _date){
       print('date selected: ${_date.toString()}');
       setState(() {
         _date = picked;
       });
     }
     _selectTime(context);
   }

    Future<void> _selectTime(BuildContext context) async {
     int Csec,Cmin,Chour,Cday;
     TimeOfDay now = TimeOfDay.now()
     final TimeOfDay picked = await showTimePicker(
         context: context,
         initialTime: _time
     );
     if(picked != null && picked != _time){
       print('time selected: ${_time.toString()}');
       setState(() {
         _time = picked;
       });
     }
    }


i wanted to put every single thing in its own int (Csec,Cmin,Chour...) but i dont know if it will work.

0 个答案:

没有答案