Ola Prof, Estou pegando este erro, tentei fazer o mesmo da duvida já apontada abaixo, mas não deu certo.
class ListaTransferencias extends StatelessWidget{
final List<Transferencia> _transferencias = [];
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
backgroundColor: primaryColor,
title: Text('Transferências'),
),
body: ListView.builder(
itemCount: _transferencias.length,
itemBuilder: (context, indice) {
final transferencia = _transferencias[indice];
return ItemTransferencia(transferencia);
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
backgroundColor: Colors.green,
onPressed: () {
final Future<Transferencia> future =
Navigator.push(context, MaterialPageRoute(builder: (context) {
return FormularioTransferencia();
}));
future.then((transferenciaRecebida) {
debugPrint('chegou no then do future');
debugPrint('$transferenciaRecebida');
_transferencias.add(transferenciaRecebida);
});
},),
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
color: primaryColor,
child: Container(height: 50)
),
);
}
}
Performing hot reload... Syncing files to device AOSP on IA Emulator... lib/main.dart:107:21: Error: A value of type 'Future' can't be assigned to a variable of type 'Future'.
- 'Future' is from 'dart:async'.
- 'Transferencia' is from 'package:bytebank/main.dart' ('lib/main.dart').
Navigator.push(context, MaterialPageRoute(builder: (context) { ^