Chris1234567899 / flutter_time_range_picker

A time range picker for Flutter
MIT License
33 stars 53 forks source link

Background widget function does not respond to setState #20

Closed TolgaYld closed 2 years ago

TolgaYld commented 3 years ago

Hi,

If the values ​​in the variables change, the variables in the background widget method do not change, although they were changed in the SetState.

thanks in advance! :)

Chris1234567899 commented 2 years ago

I think this was a limitation by flutter at that time. It appears to be fixed now.

If I understand you correctly, you meant something like this?


  String _startText = "init";
  String _endText = "init";
 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: ListView(children: [
        TimeRangePicker(
          hideButtons: true,
          hideTimes: true,
          backgroundWidget: Column(
            children: [
              Text(_startText),
              Text(_endText),
            ],
          ),
          onStartChange: (time) {
            setState(() {
              _startText = "Start: " + time.format(context).toString();
            });
          },
          onEndChange: (time) {
            setState(() {
              _endText = "End: " + time.format(context).toString();
            });
          },
        ),
      ]),
    );

I will close this issue. If you referred to something different or have other issues, feel free to reopen it or create a new one.