vi-k / bubble

Speech bubble for Flutter
BSD 2-Clause "Simplified" License
266 stars 57 forks source link

Dynamic list of bubbles #35

Open dweberlj opened 3 years ago

dweberlj commented 3 years ago

Hello,

I have the following code to implement a dynamic list of chat bubbles. The issue is that in the setState the bubbles are not redrawn. Could you please provide an example of dynamically generating bubbles.

Also, how do I autoscroll to the bottom that new bubbles are added?

Thank you.

List<Widget> bubbles = <Widget>[];

void onSomeEvent() {
    setState(() {
        bubbles.add(new Bubble(color: Colors.blue, child: new Text('Hello Bubble');
    }
}

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Quantum AI Scribe"),
      ),
      body: Container(
        color: Colors.black12,
        child: ListView(
          padding: const EdgeInsets.all(8),
          children: bubbles,
        ),
      )
    );
 }