Bom dia, estou começando agora no mundo flutter e estou montando uma TabBarView com card com dados vindos de um banco. Estou colocando dentro de ListView para poder separar nas tabs e carregando os dados dentro de um ListView.builder. Ao debuggar, vi que os dados estão sendo pegos, porém gera um erro e não carrega na tela. O erro é:
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderViewport#0e7dd NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1702 pos 12: 'hasSize'
════════ Exception caught by rendering library ═════════════════════════════════
The getter 'scrollOffsetCorrection' was called on null.
Receiver: null
Tried calling: scrollOffsetCorrection
A classe de montagem de tela:
class _LacamentosWidgetState extends State<LacamentosWidget> {
@override
Widget build(BuildContext context) {
Lancamentos _lancamentos = Provider.of(context);
return TabBarView(
children: <Widget>[
//aba despesas
ListView(
children: <Widget>[
Card(
margin: EdgeInsets.all(10),
child: Column(
children: <Widget>[
ListTile(
title: Text('Descrição'),
),
],
),
)
],
),
//aba receitas
ListView(
children: <Widget>[
ListView.builder(
itemCount: _lancamentos.itemsCount,
itemBuilder: (_, int position) {
final item = position;
return Card(
child: ListTile(
title: Text('sdfd'),
),
);
}),
],
),
],
);
}
}
e a classe de pega os dados:
class Lancamento {
final int id;
final String descLancamento;
final DateTime diaLancamento;
final double valorLancamento;
final bool isReceita;
final String tipoLancamento; //FIXO VARIAVEL para enum
Lancamento({
this.id,
this.descLancamento,
this.diaLancamento,
this.valorLancamento,
this.isReceita = true,
this.tipoLancamento,
});
}
class Lancamentos with ChangeNotifier {
List<Lancamento> _items = DUMMY_LANCAMENTOS;
List<Lancamento> get items {
return [..._items];
}
int get itemsCount {
return _items.length;
}
}