getRefreshRateInfo method
Implementation
@override
Future<Map<String, dynamic>> getRefreshRateInfo() async {
if (!_checkPlatform()) {
// Nothing can be requested here, but Flutter still knows the rate
final refreshRate = _displayRefreshRate;
return {
'platform': _platformName,
'supported': false,
'message': 'Refresh rate control not supported on this platform',
if (refreshRate != null) ...{
'currentRefreshRate': refreshRate,
'currentFramesPerSecond': refreshRate,
},
};
}
final defaultResult = {'platform': _platformName, 'supported': true};
final result =
(await _invoke<Map<dynamic, dynamic>>(
'getRefreshRateInfo',
))?.cast<String, dynamic>();
if (result == null) {
return defaultResult;
}
// Due to a typo, Android has currentRefreshRate and iOS has currentFramesPerSecond.
// So now you can use either :P
result['currentRefreshRate'] ??= result['currentFramesPerSecond'];
result['currentFramesPerSecond'] ??= result['currentRefreshRate'];
return Map<String, dynamic>.from(defaultResult)..addAll(result);
}