0

When I type something in the TextField it is not stored in allNotes variable by the snapshot

Even if any input is given the snapshot.data doesnot store any data in allNotes

There are two different files one file take the input from the TextField and another file has the snapshot which stores the data in allNotes.

The condition snapshot.hasData is true than empty list is received.

code accepting input from TextField

return Scaffold(
      appBar: AppBar(title : const Text('New Note')),
      body: FutureBuilder(
        future: createNewNote(),
        builder: (context, snapshot) {
          switch(snapshot.connectionState){ 
            case ConnectionState.done:            
            _note = snapshot.data;
            _setupTextControllerListener();

            //Take input from user
              return TextField(
                controller: _textController,
                keyboardType: TextInputType.multiline,
                maxLines: null,
                decoration: const InputDecoration(
                  hintText : 'Start typing your note...',
                ), 
              );
            default:
              return const CircularProgressIndicator();
          }
        },
      ),
    );

Code having snapshot

switch(snapshot.connectionState){
                      case ConnectionState.waiting:
                      case ConnectionState.active:
                        if(snapshot.hasData){
                          final allNotes = snapshot.data as List<DatabaseNote>;
                          print(allNotes);  // Empty list is returned
                          return const Text('Got all Notes');
                        }else{
                          return const CircularProgressIndicator();
                        }


                      default:
                        return const CircularProgressIndicator();
                    }
                  },
                );
              default :
                return const CircularProgressIndicator();
            }

I want that the data inputed through the TextField should be stored in the allNotes variable in the form of List, but instead I am receiving empty list. I tried converting snapshot.data to list but not able to even if input was provided through textfield. I am not receiving any error or Exception just receiving an empty list instead of the list with output.

0 Answers0