Skip to content

Commit 90f96de

Browse files
修复ios编译不通过问题
1 parent 7706a9d commit 90f96de

File tree

5 files changed

+42
-40
lines changed

5 files changed

+42
-40
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
- 解决ios编译不通过问题
4+
15
## 1.0.0
26

37
- 调整 android 软键盘获取高度方式

example/.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"keyboard_utils_fork","path":"/Users/10457/flutter_project/keyboard_utils/","native_build":true,"dependencies":[]}],"android":[{"name":"keyboard_utils_fork","path":"/Users/10457/flutter_project/keyboard_utils/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"keyboard_utils_fork","dependencies":[]}],"date_created":"2023-11-09 10:55:07.134059","version":"3.7.12"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"keyboard_utils_fork","path":"/Users/yinxu/flutter-project/keyboard_utils/","native_build":true,"dependencies":[]}],"android":[{"name":"keyboard_utils_fork","path":"/Users/yinxu/flutter-project/keyboard_utils/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"keyboard_utils_fork","dependencies":[]}],"date_created":"2023-11-09 22:52:15.124662","version":"3.7.12"}

example/lib/input_page.dart

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,41 @@ class _InputPageState extends State<InputPage> {
8484
final viewInsetsBottom = MediaQuery.of(context).viewInsets.bottom;
8585
final viewPaddingBottom = MediaQuery.of(context).viewPadding.bottom;
8686

87-
return Center(
88-
child: Column(
89-
children: <Widget>[
90-
Container(
91-
margin: const EdgeInsets.only(bottom: 30),
92-
child: Text(
93-
'当前顶部安全距离:$tempSafeTopHeight'
94-
'\n当前底部安全距离:$tempSafeBottomHeight'
95-
'\n当前底部距离:$viewPaddingBottom'
96-
'\n软键盘是否开启: ${_keyboardUtils.isKeyboardOpen}'
97-
'\n软键盘高度: $viewInsetsBottom'
98-
'\n屏幕密度: $devicePixelRatio'
99-
'\n动态软键盘高度: $tempKeyBoardHeight',
87+
return Container(
88+
padding: EdgeInsets.only(
89+
bottom: MediaQuery.of(context).padding.bottom,
90+
),
91+
child: Center(
92+
child: Column(
93+
children: <Widget>[
94+
Container(
95+
margin: const EdgeInsets.only(bottom: 30),
96+
child: Text(
97+
'当前顶部安全距离:$tempSafeTopHeight'
98+
'\n当前底部安全距离:$tempSafeBottomHeight'
99+
'\n当前底部距离:$viewPaddingBottom'
100+
'\n软键盘是否开启: ${_keyboardUtils.isKeyboardOpen}'
101+
'\n软键盘高度: $viewInsetsBottom'
102+
'\n屏幕密度: $devicePixelRatio'
103+
'\n动态软键盘高度: $tempKeyBoardHeight',
104+
),
100105
),
101-
),
102-
Spacer(),
103-
Container(
104-
height: 50,
105-
padding: EdgeInsets.symmetric(horizontal: 16),
106-
child: TextField(
107-
// keyboardType: TextInputType.number,
108-
decoration: InputDecoration(
109-
hintText: '请输入',
106+
Spacer(),
107+
Container(
108+
height: 50,
109+
padding: EdgeInsets.symmetric(horizontal: 16),
110+
child: TextField(
111+
// keyboardType: TextInputType.number,
112+
decoration: InputDecoration(
113+
hintText: '请输入',
114+
),
110115
),
111116
),
112-
),
113-
Container(
114-
height: tempKeyBoardHeight,
115-
),
116-
],
117+
Container(
118+
height: tempKeyBoardHeight,
119+
),
120+
],
121+
),
117122
),
118123
);
119124
}

ios/Classes/SwiftKeyboardUtilsPlugin.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import Flutter
22
import UIKit
33

4-
//
5-
// SwiftKeyboardUtilsPlugin.swift
6-
// keyboard_utils
7-
//
8-
// Created by Isaías Santana on 25/10/19.
9-
//
10-
114
public class SwiftKeyboardUtilsPlugin: NSObject, FlutterPlugin ,FlutterStreamHandler {
125
private var eventSink: FlutterEventSink?
136
private var isKeyboardOpen = false
@@ -46,17 +39,17 @@ public class SwiftKeyboardUtilsPlugin: NSObject, FlutterPlugin ,FlutterStreamHan
4639
private func registerEvents() {
4740
NotificationCenter.default.addObserver(self,
4841
selector: #selector(keyboardWillShow),
49-
name: NSNotification.Name.UIKeyboardWillShow,
42+
name: UIResponder.keyboardWillShowNotification,
5043
object: nil)
5144

5245
NotificationCenter.default.addObserver(self,
5346
selector: #selector(keyboardWillHide),
54-
name: NSNotification.Name.UIKeyboardWillHide,
47+
name: UIResponder.keyboardWillHideNotification,
5548
object: nil)
5649

5750
NotificationCenter.default.addObserver(self,
5851
selector: #selector(keyboardDidShow),
59-
name: NSNotification.Name.UIKeyboardDidShow,
52+
name: UIResponder.keyboardDidShowNotification,
6053
object: nil)
6154
}
6255

@@ -70,7 +63,7 @@ public class SwiftKeyboardUtilsPlugin: NSObject, FlutterPlugin ,FlutterStreamHan
7063

7164
@objc private func checkIsKeyboardOpen(notification: Notification) {
7265
func keyboardHeight() -> Double? {
73-
if let keyboardFrame: NSValue = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
66+
if let keyboardFrame: NSValue = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue {
7467
let keyboardRectangle = keyboardFrame.cgRectValue
7568
return Double(keyboardRectangle.height)
7669
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: keyboard_utils_fork
22
description: fork from https://github.com/IsaiasSantana/keyboard_utils
3-
version: 1.0.0
3+
version: 1.0.1
44
homepage: https://github.com/hello-coder-xu/keyboard_utils.git
55

66
environment:

0 commit comments

Comments
 (0)