scenario: have an application in flutter with a hard-coded list of 20 cards after a release build of this on my 120 fps devices it still feels like 60 fps how to fix it while the native android counterpart has a smooth render at 120 fps.
have tries the above scenario will the scrolling based widget both builder-based and normal ones.
Is it a flaw in flutter that it doesn't render at 120 fps.
On Android phones with 120hz display by default is chosen the wrong display mode (e.g. 60hz instead 120hz). This can easily be corrected, then performance on phones like Oneplus 8T or Galaxy S20+ is great.
flutter_displaymode library:flutter_displaymode: ^0.3.0-nullsafety.0
class _YourAppState extends State<YourApp> {
@override
void initState() {
setOptimalDisplayMode();
super.initState();
}
Future<void> setOptimalDisplayMode() async {
final List<DisplayMode> supported = await FlutterDisplayMode.supported;
final DisplayMode active = await FlutterDisplayMode.active;
final List<DisplayMode> sameResolution = supported.where(
(DisplayMode m) => m.width == active.width
&& m.height == active.height).toList()..sort(
(DisplayMode a, DisplayMode b) =>
b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode = sameResolution.isNotEmpty
? sameResolution.first
: active;
/// This setting is per session.
/// Please ensure this was placed with `initState` of your root widget.
await FlutterDisplayMode.setPreferredMode(mostOptimalMode);
}
}
Note, that right now there are no 120hz iPhones, so there is no need to execute them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With