E/flutter (19434): [ERROR:flutter/runtime/dartvminitializer.cc(41)] Unhandled Exception:…
- User
E/flutter (19434): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'int' class TypeAnnonce { int id; String libelle;
TypeAnnonce({required this.id, required this.libelle});
factory TypeAnnonce.fromJson(Map<String, dynamic> json) { return TypeAnnonce( id: json['idType'], libelle: json['libelleType'], ); } } static Future<List> buildTypesAnnonceDistant() async { final data = await tqd.TypeAnnonceQueries.getTypeAnnonces().then((value) => value);
List<TypeAnnonce> typesAnnonce = []; for (var typeAnnonce in data) { print(typeAnnonce); typesAnnonce.add(TypeAnnonce.fromJson(typeAnnonce)); } return typesAnnonce;}import 'package:flutter/material.dart'; import 'package:sae_mobile/models/TypeAnnonce.dart' as taq; import 'package:sae_mobile/models/Builder.dart' as builder_model; import 'package:flutter/material.dart'; import 'package:sae_mobile/models/queries/local/typeAnnonce.dart' as taq;
class CategoryListPage extends StatefulWidget { @override _CategoryListPageState createState() => _CategoryListPageState(); }
class _CategoryListPageState extends State { late Future<List<taq.TypeAnnonce>> _typeAnnonceList;
@override void initState() { super.initState(); _typeAnnonceList = builder_model.Builder.buildTypesAnnonceDistant(); _typeAnnonceList.then((value) { print('Valeur de _typeAnnonceList: $value'); }); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Catégorie'), ), body: FutureBuilder<List<taq.TypeAnnonce>>( future: _typeAnnonceList, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } else if (snapshot.hasError) { return Center(child: Text('Erreur: {snapshot.error}')); } else { return ListView.builder( itemCount: snapshot.data!.length, itemBuilder: (context, index) { final typeAnnonce = snapshot.data![index]; print('Les catégorie sont: typeAnnonce'); print(typeAnnonce); return ListTile( title: Text(typeAnnonce.libelle), ); }, ); } }, ), ); } }
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.