bugfix: add refresh rate to log output

This commit is contained in:
Anton Stubenbord
2023-02-11 13:12:11 +01:00
parent cea85e000d
commit 95a26f4bb6

View File

@@ -197,21 +197,6 @@ void main() async {
); );
} }
Future<void> setOptimalDisplayMode() async {
final List<DisplayMode> supported = await FlutterDisplayMode.supported;
final DisplayMode active = await FlutterDisplayMode.active;
final List<DisplayMode> sameResolution = supported
.where((m) => m.width == active.width && m.height == active.height)
.toList()
..sort((a, b) => b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode =
sameResolution.isNotEmpty ? sameResolution.first : active;
await FlutterDisplayMode.setPreferredMode(mostOptimalMode);
}
class PaperlessMobileEntrypoint extends StatefulWidget { class PaperlessMobileEntrypoint extends StatefulWidget {
const PaperlessMobileEntrypoint({ const PaperlessMobileEntrypoint({
Key? key, Key? key,
@@ -296,7 +281,7 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
// Temporary Fix: Can be removed if the flutter engine implements the fix itself // Temporary Fix: Can be removed if the flutter engine implements the fix itself
// Activate the highest supported refresh rate on the device // Activate the highest supported refresh rate on the device
if (Platform.isAndroid) { if (Platform.isAndroid) {
setOptimalDisplayMode(); _setOptimalDisplayMode();
} }
initializeDateFormatting(); initializeDateFormatting();
// For sharing files coming from outside the app while the app is still opened // For sharing files coming from outside the app while the app is still opened
@@ -308,6 +293,22 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
.then(ShareIntentQueue.instance.addAll); .then(ShareIntentQueue.instance.addAll);
} }
Future<void> _setOptimalDisplayMode() async {
final List<DisplayMode> supported = await FlutterDisplayMode.supported;
final DisplayMode active = await FlutterDisplayMode.active;
final List<DisplayMode> sameResolution = supported
.where((m) => m.width == active.width && m.height == active.height)
.toList()
..sort((a, b) => b.refreshRate.compareTo(a.refreshRate));
final DisplayMode mostOptimalMode =
sameResolution.isNotEmpty ? sameResolution.first : active;
debugPrint('Setting refresh rate to ${mostOptimalMode.refreshRate}');
await FlutterDisplayMode.setPreferredMode(mostOptimalMode);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocConsumer<AuthenticationCubit, AuthenticationState>( return BlocConsumer<AuthenticationCubit, AuthenticationState>(