I'm trying out Flutter and my app is responding very very slow on both the emulator and real device. I get warnings like this
Skipped 51 frames! The application may be doing too much work on its main thread.
I'm aware Dart is a single-threaded programming language and in Android I used to solve this with the good old new Thread();
block for async. I am trying to apply the same in Flutter and I reading through Future
await
async
and the sorts but the examples seem to be addressing when you reading data from the internet. My app doesn't read anything online at this stage, I'm getting Skipped x frames when my screen has progress dialog, when I am opening a new screen/page, and with every animation on the app. Here is an example of the class where I am getting the issue:
_buildContent(){
return new Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new InkWell(
onTap: (){
Navigator.push(context, new MaterialPageRoute(builder:
(context) => new LoginScreen()));
},
child: new Container(
height: 150.0,
width: 150.0,
child: new Image.asset("images/logo.png", fit: BoxFit.cover,),
),
),
new Container(
margin: const EdgeInsets.all(16.0),
child: new CircularProgressIndicator(
value: null,
strokeWidth: 1.0,
valueColor: new AlwaysStoppedAnimation<Color>(
Colors.white
)
),
)
],
);
}
I'm assuming the skipped x frames warning is caused by the progress dialog? I have another screen (Login Screen) which animates widgets into place when opened, the animations move so slow, I can literally see each frame being rendered. Is there a tutorial online that can assist with addressing this or just understanding Dart's Asynchronous Programming?
flutter build apk --release
. Bigger images in animated widgets are known to cause performance issues. – Günter ZöchbauerFuture
isn't a different thread though – Rémi RousseletObservatory
to trace what's costing that much. – Rémi RousseletFuture
, it'll freeze your app – Rémi RousseletFuture
is not a thread. – matanlurey