How to increment value? in Flutter, I need to increment the value from 1 - 3 without adding firestore data 1, 2, 3
in it, any help is highly appreciated. This is my code and kindly check image below for reference. Thank you
return FutureBuilder<DocumentSnapshot>(
future: users.doc(widget.documentId).get(),
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.done){
Map<String, dynamic> data = {};
data = snapshot.data?.data() as Map<String, dynamic>;
increment ;
return Column(
children: [
Row(
children: [
Container(
color: Colors.red[200],
width: 50,
child: Text(
increment.toString(), //<- increment this value
style: TextStyle(
fontSize: SizeConfig.safeBlockHorizontal * 2.7,
)
),
),
Container(
color: Colors.green[200],
width: 270,
child: Text(
data['fullName'],
style: TextStyle(
fontSize: SizeConfig.safeBlockHorizontal * 3.06,
),
),
),
],
),
Divider(thickness: SizeConfig.safeBlockHorizontal * .27),
],
);
}
Text("Loading.."),
},
);
CodePudding user response:
Try this you will index.
body: FutureBuilder<List<String>?>(
future: getData(),
builder: (context, snapshot) {
if (snapshot.hasData &&
snapshot.connectionState == ConnectionState.done) {
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
return Text(snapshot.data?[index] ?? "got null");
},
);
}
/// handles others as you did on question
else {
return CircularProgressIndicator();
}
},
CodePudding user response:
Permission to admin or moderator, kindly delete this question, thanks to @Mahesh answer but I rather used StreamBuilder to make this work, and its now working fine. Thank you. Kindly close or delete this thread