I have a FutureBuilder widget which retrieves chats (or rather updates) from the server and displays them. Here is the code:
Future<List<Chat>> fetchChats(http.Client client, String providerUUID) async {
returns List<Chat>..
}
class ProviderChats extends StatelessWidget {
final List<Chat> chats;
final String providerUUID;
ProviderChats({this.chats, this.providerUUID});
@override
Widget build(BuildContext context) {
return FutureBuilder<List<Chat>>(
future: fetchChats(http.Client(), providerUUID),
builder: (context, snapshot){
if(snapshot.hasError) print(snapshot.error);
return snapshot.hasData ?
ChatsListWidgetClass(chats: snapshot.data) :
Center(child: CircularProgressIndicator());
},
);
}
}
class ChatsListWidgetClass extends StatelessWidget {
final List<Chat> chats;
ChatsListWidgetClass({this.chats});
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: chats.length,
itemBuilder: (context, index) {
return Card(
elevation: 10.0,
child: Column(
children: <Widget>[
Text(
chats[index].message,
),
Text(
chats[index].createdAt,
),
],
),
);
},
);
}
}
It looks something like this:
At the bottom of the screen, I want to show a TextField with a Send button (just like what we see on chat screens). But I am unable to accommodate my ListView.builder inside a Column.
Is there a way to make the list occupy 80% of the vertical space from top and make the send textfield occupy the bottom 20%. Basically like a chat application window.

