enter image description here[enter image description here][2] Future _getName() async{ return await Firestore.instance.collection("admin_details").document(_username).get(); }
FutureBuilder<DocumentSnapshot>(
future: _getName(),
builder: (context,snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasData) {
if (snapshot.data != null) {
return Text(snapshot.data['first_name']);
}
else {
return Text("Loading...");
}
}
else {
return Text("No Data");
}
}
else{
return null;
}
}
),
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following NoSuchMethodError was thrown building FutureBuilder(dirty, state: _FutureBuilderState#8f31b): The method '[]' was called on null. Receiver: null Tried calling:
The relevant error-causing widget was: FutureBuilder file:///D:/Flutter/ecoleami1_0/lib/StudentActivity.dart:52:28 When the exception was thrown, this was the stack:
0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
1 DocumentSnapshot.[] (package:cloud_firestore/src/document_snapshot.dart:31:42)
2 _StudentActivityPageState.build. (package:ecoleami1_0/StudentActivity.dart:57:50)
3 _FutureBuilderState.build (package:flutter/src/widgets/async.dart)
4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4334:27)
... ════════════════════════════════════════════════════════════════════════════════════════════════════
Can anyone help me, please?