Reputation: 253
I am using listview. builder inside singlechildScrollview but when I am scrolling through listview it is lagging. what is the solution to prevent lagging effect?
This issue is in release mode itself, so how to remove this lagging problem?
body: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
deviceSize.width > 768 ? SideLayout() : Container(),
Expanded(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: deviceSize.width > 768 ? 50 : 2.5,
),
Padding(
padding: deviceSize.width > 768
? EdgeInsets.all(8)
: EdgeInsets.symmetric(horizontal: 20, vertical: 5.0),
child: Container(
width: deviceSize.width > 768 ? 780 : deviceSize.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
LatestButton(),
],
),
),
),
SizedBox(
height: deviceSize.width > 768 ? 20 : 0,
),
ListView.builder(
padding: deviceSize.width > 768 ? EdgeInsets.only(left: 120, right: 200) : EdgeInsets.all(0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: 9,
itemBuilder: (context, index) {
return PollCard();
}),
],
),
),
),
],
),
Upvotes: 5
Views: 7618
Reputation: 1
I got your issue. This is not because you have trouble in your code. It's because your shaders are not precompiled. Skia engine performs better when shader's are precompiled. That will help you to avoid those janky frames.
Do As Following
flutter run --profile --cache-sksl --purge-persistent-cache
Perform transitions and animation as much as possible in your app. Then PRESS M to save shader file eg. name.sksl.json
Run to build your app with compiled shaders
Android:
flutter build apk --bundle-sksl-path flutter_01.sksl.json
Ios:
flutter build ios --bundle-sksl-path flutter_01.sksl.json
Test release apk in your device.
I hope This will help you.
Upvotes: 0
Reputation: 937
Use this in your ListView.builder
primary: false,
Don't use
physics = NeverScrollableScrollPhysics();
Upvotes: 5