fix: android 14 issues (#649)

This commit is contained in:
Lucas.Xu 2024-01-05 13:50:01 +07:00 • committed by GitHub
commit 3f5663697d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View file

@ -90,7 +90,12 @@ class _TextDecorationMenuState extends State<_TextDecorationMenu> {
isSelected: isSelected,
onPressed: () {
setState(() {
widget.editorState.toggleAttribute(currentDecoration.name);
widget.editorState.toggleAttribute(
currentDecoration.name,
selectionExtraInfo: {
selectionExtraInfoDoNotAttachTextService: true,
},
);
});
},
);

View file

@ -1,3 +1,6 @@
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:keyboard_height_plugin/keyboard_height_plugin.dart';
typedef KeyboardHeightCallback = void Function(double height);
@ -5,7 +8,14 @@ typedef KeyboardHeightCallback = void Function(double height);
// the KeyboardHeightPlugin only accepts one listener, so we need to create a
// singleton class to manage the multiple listeners.
class KeyboardHeightObserver {
static int androidSDKVersion = -1;
KeyboardHeightObserver._() {
if (Platform.isAndroid && androidSDKVersion == -1) {
DeviceInfoPlugin().androidInfo.then(
(value) => androidSDKVersion = value.version.sdkInt,
);
}
_keyboardHeightPlugin.onKeyboardHeightChanged((height) {
currentKeyboardHeight = height;
notify(height);
@ -32,6 +42,13 @@ class KeyboardHeightObserver {
}
void notify(double height) {
// the keyboard height will notify twice with the same value on Android 14
if (androidSDKVersion == 34) {
if (height == 0 && currentKeyboardHeight == 0) {
return;
}
}
for (final listener in _listeners) {
listener(height);
}

View file

@ -48,6 +48,7 @@ dependencies:
universal_html: ^2.2.4
keyboard_height_plugin: ^0.0.4
numerus: ^2.1.2
device_info_plus: ^9.1.1
dev_dependencies:
flutter_test: