- I am trying to implement
Searchbar
for my application which will search according to user'sfirstName
. - I am facing the below error saying
The method '[]' can't be unconditionally invoked because the receiver can be 'null'.
Try making the call conditional (using '?.') or adding a null check to the target ('!').
- Code
late QuerySnapshot snapshotData;
..
..
title: Text(snapshotData.docs[index].data()['firstName'], style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 24.0
),
),
CodePudding user response:
Use
Text(snapshotData.docs[index].get('firstName'))