I want to load the data saved in a SQlite database into Flutter. I don't want to use the FutureBuilder method since it generates a widget and what I need is to do some validation procedures.
I am using the code:
Future cargarcarros() async {
final carros = await DBProvider.db.getTodosVehiculos();
for (int i = 1; i <= carros.length; i++) {
final db = await DBProvider.db.getVehiculoId(i);
String placanumero = db.placa.replaceAll(RegExp(r'[a-zA-Z]'), "");
String ultimo = placanumero.substring(placanumero.length - 1);
//shownotification(db.placa);
return print(ultimo);
}
{
}
This code only returns the first value of the list of items from the database.
How can I manage to load all the items and make the iteration work correctly.
If you don't want to use
FutureBuilder
orStreams
, you can do it the easiest way withStatefulWidget
.Assuming you're inside the State class of the StatefulWidget :