andyduke / styled_text_package

Text widget with formatted text using tags. Makes it easier to use formatted text in multilingual applications.
https://pub.dev/packages/styled_text
BSD 3-Clause "New" or "Revised" License
74 stars 48 forks source link

Fix error on unmounted state. #34

Closed ryanheise closed 3 years ago

ryanheise commented 3 years ago

I was getting this error:

I/flutter (15201): ### Zone error: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
I/flutter (15201): Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
I/flutter (15201): ### #0      State.context.<anonymous closure> (package:flutter/src/widgets/framework.dart:909:9)
I/flutter (15201): #1      State.context (package:flutter/src/widgets/framework.dart:915:6)
I/flutter (15201): #2      _StyledTextState._updateTextSpans.<anonymous closure> (package:styled_text/styled_text.dart:376:47)

I've extended the guarded block to ensure context isn't accessed if unmounted.