during firebase connection, I get an error type 'String' is not a subtype of type 'int'
class _VeriTabaniState extends State<VeriTabani> {
@override
Widget build(BuildContext context) {
return _buildBody(context, sahteSnapshot);
}
Widget _buildBody(BuildContext context, List<Map> snapshot) {
return ListView(
padding: EdgeInsets.only(top: 25.0),
//buildListItem ztn bir liste, children i?ine al?r direk
children:
//sahte datalardan gelen her?ey i?in d?ndürece?im
//buildListItem'? creat method ile olu?turdum
snapshot
.map<Widget>((data) => _buildListItem(context, data))
.toList(),
);
}
_buildListItem(BuildContext context, Map data) {
//sahtelerden her gelen i?in yeni bir kay?t üretecek
final kayitWidget = Kayit.fromMap(data);
return Padding(
//biz bunlara t?klar?z m?klar?z, hangisinin oldu?unu anlamak i?in key
key: ValueKey(kayitWidget.okulisim),
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.2),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent),
borderRadius: BorderRadius.circular(5.0)),
child: ListTile(
title: Text(kayitWidget.okulisim),
trailing: Text(kayitWidget.sayi.toString()),
//firebase'e yollayaca??z
onTap: () => {},
),
),
);
}
}
//sahte veriler olu?tural?m
final sahteSnapshot = [
{"okulisim": "Sau", "sayi": "1"},
{"okulisim": "Metu", "sayi": "2"},
{"okulisim": "Kou", "sayi": "3"},
{"okulisim": "Boun", "sayi": "4"},
];
class Kayit {
String okulisim;
String sayi;
DocumentReference reference;
//kayit icin bir constructer olu?tural?m
//fb icin ?ok kullan?lan bir yap?s? var bunlar?n
Kayit.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map["okulisim"] != null),
assert(map["sayi"] != null),
okulisim = map["okulisim"],
sayi = map["sayi"];
//dbdeki anl?k de?isimler
Kayit.fromSnapshot(DocumentSnapshot snapshot)
: this.fromMap(snapshot.data(), reference: snapshot.reference);
@override
String toString() => "Kay?t<$okulisim : $sayi>";
}
is actually where I get the int String error:
Kayit.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map["okulisim"] != null),
assert(map["sayi"] != null),
okulisim = map["okulisim"],
sayi = map["sayi"];
and it fixes when I make the variable int to String
class Kayit {
String okulisim;
String sayi;
DocumentReference reference;
//kayit icin bir constructer olu?tural?m
//fb icin ?ok kullan?lan bir yap?s? var bunlar?n
Kayit.fromMap(Map<String, dynamic> map, {this.reference})
: assert(map["okulisim"] != null),
assert(map["sayi"] != null),
okulisim = map["okulisim"],
sayi = map["sayi"];
How?