简体   繁体   中英

Flutter - setState called after dispose()

I have a TextFieldController in my app, but everytime I type anything in it using my keyboard my entire app reloads and shows me the error,

Error: setState() called after dispose(): _SlidingPanelState#65b14(lifecycle state: defunct, not mounted)

The error seems related to SlidingPanel but I'm not sure why is it interfering with TextFieldController.

  SliverToBoxAdapter(
                  child: Container(
                    height: 100,
                    padding: const EdgeInsets.all(20.0),
                    child: TextField(
                      decoration: InputDecoration(
                          border: InputBorder.none,
                          labelText: 'Enter Name',
                          hintText: 'Enter Your Name'),
                    ),
                  ),
                ),

Find in your _SlidingPanelState

setState(() {);

and change it

if (mounted) {
   setState(() {);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM