I have a stream of a fast-changing data:
final dataStream = Stream<List<int>>.periodic(
const Duration(milliseconds: 30),
(count) => List.generate(30, (i) => count + i),
);
And I want to perform a live update of the UI based on the new data:
class TestPage extends StatelessWidget {
const TestPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: StreamBuilder(
initialData: const <int>[],
stream: dataStream,
builder: (context, snapshot) {
return ListView.builder(
itemBuilder: (context, index) => Text(
'${snapshot.requireData[index]}',
),
itemCount: snapshot.requireData.length,
);
},
),
),
);
}
}
Even though, this approach works I'm suffering from a frame rate drop (the app is running in the profile mode):
Thus, I was wondering what can be improved to make it more performant?