firebase에서 int 데이터를 문자열로 반환하려고하는데 방법을 모르겠습니까? toString () 시도했지만 더해야 할 일이 있습니까?
@override
Widget build(BuildContext context) {
// <1> Use FutureBuilder
return FutureBuilder<QuerySnapshot>(
// <2> Pass `Future<QuerySnapshot>` to future
future: FirebaseFirestore.instance.collection('UserNames').get(),
builder: (context, snapshot) {
if (snapshot.hasData) {
// <3> Retrieve `List<DocumentSnapshot>` from snapshot
final List<DocumentSnapshot> documents = snapshot.data.docs;
return ListView(
children: documents
.map((doc) => Card(
child: ListTile(
title: Text(doc['displayName']),
subtitle: Text(doc['plastics']),
),
))
.toList());
} else if (snapshot.hasError) {
return Text('Its Error!');
}
});
}
문서 플라스틱은 firestore의 int 값이므로 오류가 발생한 곳입니다. int 데이터를 텍스트로 어떻게 변환합니까? 감사합니다.
두 가지 방법이 있으며 더 이상 할 수있는 것은 없습니다. :)
toString()
방법doc [ 'plastics']. toString ()
'$ {doc ['plastics ']}'
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다