diegoveloper / flutter_percent_indicator

Flutter percent indicator library
BSD 2-Clause "Simplified" License
677 stars 206 forks source link

fix: check for hasSize for linearPercentIndicator - fix #175 #176

Closed noxasch closed 2 years ago

noxasch commented 2 years ago

This PR will check for renderbox.haSize in linearPercentIndicator to fix this issue https://github.com/diegoveloper/flutter_percent_indicator/issues/175

final RenderBox box =
            _containerKey.currentContext?.findRenderObject() as RenderBox;

        if (box.hasSize) {
          setState(() {
            _containerWidth = _containerKey.currentContext?.size?.width ?? 0.0;
            _containerHeight =
                _containerKey.currentContext?.size?.height ?? 0.0;
            if (_keyIndicator.currentContext != null) {
              _indicatorWidth =
                  _keyIndicator.currentContext?.size?.width ?? 0.0;
              _indicatorHeight =
                  _keyIndicator.currentContext?.size?.height ?? 0.0;
            }
          });
        }

Not sure how to properly create a test case for this as it require nested routes to reproduce the flutter bug. But it shouldn't break any existing test.

noxasch commented 2 years ago

closing this as I cannot reproduce bare minimum in flutter.