Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check in linear percent indicator state is null if the size is null #203

Conversation

victormanuelfrancodev
Copy link
Contributor

Description:
It checks if size is null before assigning a measurement value. Sometimes it might happen that size comes as null, which is why the error occurs on certain occasions

Error:

Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown Instance of 'ErrorDescription'.
       at RenderBox.size(box.dart:2001)
       at Element.size(framework.dart:4175)
       at _LinearPercentIndicatorState.initState.<fn>.<fn>(linear_percent_indicator.dart:165)
       at State.setState(framework.dart:1109)
       at _LinearPercentIndicatorState.initState.<fn>(linear_percent_indicator.dart:164)
       at SchedulerBinding._invokeFrameCallback(binding.dart:1146)
       at SchedulerBinding.handleDrawFrame(binding.dart:1091)
       at SchedulerBinding._handleDrawFrame(binding.dart:997)

Related:

#174 (comment)

It checks if size is null before assigning a measurement value. Sometimes it might happen that size comes as null, which is why the error occurs on certain occasions
LayoutBuilder is used to get the size of the container where the widget is rendered
@@ -170,12 +170,11 @@ class _LinearPercentIndicatorState extends State<LinearPercentIndicator>
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
_containerWidth = _containerKey.currentContext?.size?.width ?? 0.0;
_containerHeight = _containerKey.currentContext?.size?.height ?? 0.0;
_containerWidth = (_containerKey.currentContext?.size != null) ? _containerKey.currentContext!.size!.width : 0.0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you revert these changes? I think this is not the root of the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the last commit 🫡

…dth = _keyIndicator.currentContext?.size?.width ?? 0.0

rollback  (_keyIndicator.currentContext?.size != null)  to _indicatorWidth = _keyIndicator.currentContext?.size?.width ?? 0.0
Copy link
Owner

@diegoveloper diegoveloper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diegoveloper diegoveloper merged commit 522b5e9 into diegoveloper:master Oct 6, 2023
diegoveloper added a commit that referenced this pull request Nov 23, 2024
* Adding progressBorderColor property on progressBar (#196)

* adding progressBorderColor on progressBar draw

* fixing border colors on linear percent and adding examples

* removing unnecessary parse comparsion on progress(double)

* refactoring border correction symmetrics

---------

Co-authored-by: Thiago Carvalho Ribeiro Bardez - TBA <[email protected]>

* fix: divide 0 error when archType is not null (#200)

* Check in linear percent indicator state is null if the size is null (#203)

* Add function return current percent value if animation is true (#206)

* Add an 'initialPercent' field to control the initial animation. (#209)

* Update master.yml

* Update release.yml

---------

Co-authored-by: Bardez <[email protected]>
Co-authored-by: Thiago Carvalho Ribeiro Bardez - TBA <[email protected]>
Co-authored-by: fenghezhou <[email protected]>
Co-authored-by: Victor Manuel Lagunas Franco <[email protected]>
Co-authored-by: Le Anh Phi <[email protected]>
Co-authored-by: Erik Fahlén <[email protected]>
diegoveloper added a commit that referenced this pull request Nov 23, 2024
* Adding progressBorderColor property on progressBar (#196)

* adding progressBorderColor on progressBar draw

* fixing border colors on linear percent and adding examples

* removing unnecessary parse comparsion on progress(double)

* refactoring border correction symmetrics

---------

Co-authored-by: Thiago Carvalho Ribeiro Bardez - TBA <[email protected]>

* fix: divide 0 error when archType is not null (#200)

* Check in linear percent indicator state is null if the size is null (#203)

* Add function return current percent value if animation is true (#206)

* Add an 'initialPercent' field to control the initial animation. (#209)

* Update master.yml

* Update release.yml

* Update release.yml

---------

Co-authored-by: Bardez <[email protected]>
Co-authored-by: Thiago Carvalho Ribeiro Bardez - TBA <[email protected]>
Co-authored-by: fenghezhou <[email protected]>
Co-authored-by: Victor Manuel Lagunas Franco <[email protected]>
Co-authored-by: Le Anh Phi <[email protected]>
Co-authored-by: Erik Fahlén <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants