I might be misunderstanding the usage of this tool but I see the following
which is not good because it goes over 16ms. That piece of red bars happens always the first time that I load a page (widget) that has a FutureBuilder:
@override
Widget build(BuildContext context) {
// Page template is a StatelessWidget that wraps a Scaffold with common widgets, nothing special
return PageTemplate(
child: FutureBuilder(
future: getList(), // <-- this takes about 1 second
builder: (context, snapshot) {
if (snapshot.hasData) {
List<Operator> list = snapshot.data;
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return MyWidget();
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
),
);
The app is in Run mode: profile
. Sometimes the page with the FutureBuilder might generate even more red bars so I am wondering:
- is this fine because I am just misunderstanding the tool? The overlays above the app tell me that on averages I am at GPU 10ms/frame and UI 6 ms/frame so it should be fine. But I can't get why sometimes I get this in the future (taken from android studio; dotted white line is 16fps limit):
I suspect the above "issue" (if we can call it issue) might happen because I am not properly using the FutureBuilder. I read this (I try to put const everywhere and I split widgets as much as I can to optimize when rebuild happens) and I think that futurebuilder rebuilds a lot so this might be the problem. But it has to rebuild to check if the future has finished! So?
thanks