ios simulator cursor fix (#652)

pull/656/head
Andy Trand 3 years ago committed by GitHub
parent ac933e07fb
commit a1eea4ded6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      lib/src/utils/platform.dart
  2. 21
      lib/src/widgets/raw_editor.dart
  3. 1
      pubspec.yaml

@ -1,3 +1,6 @@
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/foundation.dart';
bool isMobile([TargetPlatform? targetPlatform]) {
@ -23,3 +26,12 @@ bool isAppleOS([TargetPlatform? targetPlatform]) {
TargetPlatform.iOS,
}.contains(targetPlatform);
}
Future<bool> isIosSimulator() async {
if (Platform.isIOS) {
final deviceInfo = DeviceInfoPlugin();
final iosInfo = await deviceInfo.iosInfo;
return !iosInfo.isPhysicalDevice;
}
return false;
}

@ -557,13 +557,20 @@ class RawEditorState extends EditorState
if (isKeyboardOS()) {
_keyboardVisible = true;
} else {
_keyboardVisibilityController = KeyboardVisibilityController();
_keyboardVisible = _keyboardVisibilityController!.isVisible;
_keyboardVisibilitySubscription =
_keyboardVisibilityController?.onChange.listen((visible) {
_keyboardVisible = visible;
if (visible) {
_onChangeTextEditingValue(!_hasFocus);
// treat iOS Simulator like a keyboard OS
isIosSimulator().then((isIosSimulator) {
if (isIosSimulator) {
_keyboardVisible = true;
} else {
_keyboardVisibilityController = KeyboardVisibilityController();
_keyboardVisible = _keyboardVisibilityController!.isVisible;
_keyboardVisibilitySubscription =
_keyboardVisibilityController?.onChange.listen((visible) {
_keyboardVisible = visible;
if (visible) {
_onChangeTextEditingValue(!_hasFocus);
}
});
}
});
}

@ -28,6 +28,7 @@ dependencies:
diff_match_patch: ^0.4.1
i18n_extension: ^4.2.0
gallery_saver: ^2.3.2
device_info_plus: ^3.2.1
dev_dependencies:
flutter_test:

Loading…
Cancel
Save