2

Whenever my keyboard is open and I try to close the Drawer - EndDrawer it throws this error. The error doesn't occur if the keyboard is not focused.

======== Exception caught by widgets library =======================================================
The following assertion was thrown building StreamBuilder<List<SearchFieldListItem<dynamic>?>?>(dirty, state: _StreamBuilderBaseState<List<SearchFieldListItem<dynamic>?>?, AsyncSnapshot<List<SearchFieldListItem<dynamic>?>?>>#75ea8):
This widget has been unmounted, so the State no longer has a context (and should be considered defunct). 

Note: There is SearchField inside the drawer.

It shouldn't throw an error.

This is the code

    appBar:AppBar(title:Text('XYZ')),
    endDrawer: Drawer(
      child: ListView(


        children: [
          Padding(
            padding:EdgeInsets.all(10),
            child: SizedBox(
              child: const DrawerHeader(
                child: Text('Filter'),
              ),
            ),
          ),
            Padding(
              padding: EdgeInsets.all(10),
              child: Container(
                
                
                child: SearchField<Model>(
                  onSuggestionTap: (buyerValue) {},
                  ,
                ),
              ),
            ),
        ],
      ),
    ),
    body: Container(
        )
    ),
Neev Shah
  • 21
  • 4
  • Does this answer your question? [flutter error: This widget has been unmounted, so the State no longer has a context (and should be considered defunct)](https://stackoverflow.com/questions/68256069/flutter-error-this-widget-has-been-unmounted-so-the-state-no-longer-has-a-cont) – MendelG Dec 27 '22 at 00:07
  • @MendelG No, Because there is no button event. Clicking outside the drawer closes the drawer as it has been designed. – Neev Shah Dec 27 '22 at 00:14
  • Please [edit] your question to include your code. – MendelG Dec 27 '22 at 00:15

0 Answers0