The link is my situation in .mp4 for 3 secs the lagging screen. I found my screen shows some lagging situation after I dismiss the listview and update the doc.
This is my dismissible widget.
Dismissible(
direction: DismissDirection.endToStart,
background: Container(
color: Colors.red,
),
onDismissed: (DismissDirection direction) {
setState(
() {
healthGoal.removeAt(index);
healthgoalCollection
.doc("c66ae3ef-9853-4")
.update(
{
"healthGoalList": healthGoal,
},
);
},
);
},
Here is my stream builder widget that I get the data from
StreamBuilder<DocumentSnapshot>(
stream: _healthGoalStream,
builder: (context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (!snapshot.hasData) {
return const Text("No data");
}
if (snapshot.hasError) {
return const Center(child: Text('Something went wrong'));
}
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: CircularProgressIndicator(
color: Colors.red,
),
);
}
if (snapshot.connectionState == ConnectionState.active) {
Map<String, dynamic> condition =
snapshot.data?.data() as Map<String, dynamic>;
Map<String, dynamic> conditionmap =
Map<String, dynamic>.from(condition);
healthGoal.clear();
conditionmap.forEach(
(key, value) {
if (key == "healthGoalList") {
healthGoal = value;
}
if (key == "nameUpdated") {
if (value != "") {
nameupdate = value;
}
}
if (key == "agreeToGoal") {
if (value != "") {
agreeToGoal = value;
}
}
if (key == "dateTimeUpdated") {
if (value != "") {
timeget = DateTime.fromMillisecondsSinceEpoch(value);
timeupdate = f.format(timeget);
}
}
},
);
Are there any ways that can prevent this kind of lagging situation? Thanks if you can help or even give me a direction on the cause.
This is my cloud firestore data looks like
