Getting Null check operator used on a null value when widget is disposed

Hello,

I'm using getSelectedTextLines() to determine whether to show a copy IconButton that copies the selected text to the Clipboard. This feature works fine, but when the screen is popped, I get the following exception.

Is there some clean-up I need to do in the StatefulWidget's dispose method?



2 Replies 1 reply marked as answer

DB Dilli Babu Nandha Gopal Syncfusion Team December 9, 2021 02:03 PM UTC

Hi Luke, 
 
Whenever the page is popped out, widgets in the page will be disposed and it is not possible to access the state class of the widgets. So, we recommend using “?” null operator with SfPdfViewerState class and access their properties and methods.  
 
_pdfViewerkey.currentState?.getSelectedTextLines() 
 
Please let us know if you have any doubts. 
 
Regards, 
Dilli babu 


Marked as answer

LU Luke December 10, 2021 07:50 AM UTC

Thanks again Dilli, that has resolved my issue.


Loader.
Up arrow icon