im-kevin / cool_ui Goto Github PK
View Code? Open in Web Editor NEW用flutter实现一些我认为好看的UI控件,有Popover,仿Weui的Toast,自定义键盘
License: Apache License 2.0
用flutter实现一些我认为好看的UI控件,有Popover,仿Weui的Toast,自定义键盘
License: Apache License 2.0
现在是默认蒙层,但是有时候蒙层对交互阻断比较强,不符合我们产品的UI交互,所以能否提供一个阴影的方式呢?
(蒙层能去掉最好,如果无法去掉,可以自己设置为近似透明色也是OK的)
CupertinoPopoverMenuItem 能否可以自定义 icon 和 文字的颜色大小等?
你好啊,非常感谢作者的代码,我在使用中遇到一个问题。
我创建了两个 TextField,当我在一个 TextField 输入完成后,切入第二个 TextField 时,键盘收回了,需要手动再次弹出,不知道有什么方法可以让键盘保持呢
The following NoSuchMethodError was thrown building _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#ce416](dirty, dependencies: [MediaQuery], state: _OverlayEntryWidgetState#61a44):
The getter 'cutButtonLabel' was called on null.
Receiver: null
Tried calling: cutButtonLabel
The relevant error-causing widget was:
Overlay file:///Users/mac/Downloads/cool_ui-master/lib/keyboards/keyboard_root.dart:33:20
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 _CupertinoTextSelectionControls.buildToolbar (package:flutter/src/cupertino/text_selection.dart:365:44)
#2 TextSelectionOverlay._buildToolbar (package:flutter/src/widgets/text_selection.dart:556:34)
#3 _OverlayEntryWidgetState.build (package:flutter/src/widgets/overlay.dart:177:34)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4619:28)
比如聊天页面有多个自定义键盘,如何支持呢?目前我注册多个键盘 ,并自定义键盘就不生效,麻烦作者有时间看下哈~
Compiler message:
file:///Users/admin/flutter/.pub-cache/hosted/pub.flutter-io.cn/cool_ui-0.1.15/lib/keyboards/keyboard_manager.dart:107:20: Error: The argument type 'String' can't be assigned to the parameter type 'DiagnosticsNode'.
- 'DiagnosticsNode' is from 'package:flutter/src/foundation/diagnostics.dart' ('file:///Users/admin/flutter/packages/flutter/lib/src/foundation/diagnostics.dart').
Try changing the type of the parameter, or casting the argument to 'DiagnosticsNode'.
context: 'during a platform message response callback',
^
Compiler failed on /Users/admin/Desktop/WorkSpace/driver-custom/driver_custom/lib/main.dart
Error launching application on iPhone Xʀ.
复现:在NumberKeyboard.inputType的输入框输入并完成,退出页面,然后在其它页面的字符输入框中,系统键盘可以呼出,但输入任何字符,但输入框没有输入内容。
目前我的解决方法是在页面的dispose中调用以下方法,虽然能解决,但感觉不是最好的方法。
在类CoolKeyboard中增加以下方法
static dispose(){
isInterceptor = false;
BinaryMessages.setMockMessageHandler("flutter/textinput",null);
}
在引用键盘的页面调用
void dispose() {
CoolKeyboard.dispose();//销毁自定义键盘,不然其它页面输入不了
}
请大神有空看看。谢谢你及时解决上个问题(弹出键盘后返回上页后无法打开自定义键盘)
var hide = showWeuiLoadingToast(context: context, message: Text("请稍后"));
await Future.delayed(Duration(seconds: 2));
hide();
Navigator.pop(context, 'Yep');====>这个‘Yep'就返回不到上个页面了
·
长按输入框,会报这个错,下载的demo就能复现这个。
如果将app作为KeyboardRootWidget的child,那app设置的localizationsDelegates就无法使用
点击菜单到下一个界面后,如何让返回到当前界面时,把 菜单关掉啊,返回时,还是显示菜单的,
点击后到下一个界面,无论是按返回建还是pop结果 有无结果返回,都应该关掉弹出菜单才对啊!
是我设置问题,还是哪里的问题
` return CupertinoPopoverMenuList(
children: poplist.asMap().keys.map((i){
return CupertinoPopoverMenuItem(child: Text(poplist[i],style: TextStyle(height: 2.0),textAlign: TextAlign.center,),
onTap: (){
print('aaa:'+poplist[i]);
Navigator.push(context, MaterialPageRoute(builder: (context)=>baseCheck(TableTag:poplist[i]))).then((val){
print(val);
});
return false;
},
isTapClosePopover: true,
);
}).toList()
/* <Widget>[
CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"), ),
CupertinoPopoverMenuItem(leading: Icon(Icons.edit),child: Text("修改"),),
CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),)
], */
);`
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: setState() or markNeedsBuild() called when widget tree was locked.
This KeyboardMediaQuery widget cannot be marked as needing to build because the framework is locked.
The widget on which setState() or markNeedsBuild() was called was:
KeyboardMediaQuery(dependencies: [MediaQuery], state: KeyboardMediaQueryState#c8633)
#0 Element.markNeedsBuild.
package:flutter/…/widgets/framework.dart:3520
#1 Element.markNeedsBuild
package:flutter/…/widgets/framework.dart:3529
#2 State.setState
package:flutter/…/widgets/framework.dart:1133
#3 KeyboardMediaQueryState.update
package:cool_ui/keyboards/keyboard_media_query.dart:28
#4 CoolKeyboard.hideKeyboard
package:cool_ui/keyboards/keyboard_manager.dart:164
#5 CoolKeyboard.interceptorInput.
package:cool_ui/keyboards/keyboard_manager.dart:57
#6 BinaryMessages.send (package:flutter/s<…>
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: setState() or markNeedsBuild() called when widget tree was locked.
This KeyboardMediaQuery widget cannot be marked as needing to build because the framework is locked.
The widget on which setState() or markNeedsBuild() was called was:
KeyboardMediaQuery(dependencies: [MediaQuery], state: KeyboardMediaQueryState#c8633)
#0 Element.markNeedsBuild.
package:flutter/…/widgets/framework.dart:3520
#1 Element.markNeedsBuild
package:flutter/…/widgets/framework.dart:3529
#2 State.setState
package:flutter/…/widgets/framework.dart:1133
#3 KeyboardMediaQueryState.update
package:cool_ui/keyboards/keyboard_media_query.dart:28
#4 CoolKeyboard.hideKeyboard
package:cool_ui/keyboards/keyboard_manager.dart:164
#5 CoolKeyboard.interceptorInput.
package:cool_ui/keyboards/keyboard_manager.dart:57
#6 BinaryMessages.send (package:flutter/s<…>
如题,
已按说明,在Flutter sdk从1.12升级到1.17后(在这里我切换为beta channel的1.18也是一样的现象),同步将本插件从0.4.1升级到0.5.3版本。
问题现象:虽然两个textField使用了相同的inputype,但就像是使用了两个不同的inputype那样,切换焦点后,键盘也会收起再弹出。
期望:在inputype未发生变化时,textField之间焦点切换,键盘可不发生收起、弹出动作。
dependencies:
cool_ui: "^0.5.3"
$ flutter doctor -v
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Mac OS X 10.15.3 19D76, locale
zh-Hans-CN)
• Flutter version 1.18.0-11.1.pre at /Users/peter/Data/flutter
• Framework revision 2738a1148b (10 days ago), 2020-05-13 15:24:36 -0700
• Engine revision ef9215ceb2
• Dart version 2.9.0 (build 2.9.0-8.2.beta)
或者说怎么判断是不是已经弹出?
如题,在你的Demo例子上,
TextField( decoration: InputDecoration(labelText: '演示键盘弹出后滚动'), keyboardType: NumberKeyboard.inputType, onSubmitted: (txt){ print('aaaaaaaa'); }, ), TextField( decoration: InputDecoration(labelText: '多个键盘演示'), keyboardType: TestKeyboard.inputType, onSubmitted: (txt){ print('bbbbbbb'); }, )
加上onSubmitted,当键盘弹出时,按返回键,就会自动促发onSubmitted
导致有两个键盘切换的时候有一系列报错,github上的代码没有问题
异常:
════════ (25) Exception caught by scheduler library ════════════════════════════════════════════════
SemanticsNode#623(Rect.fromLTRB(0.0, 0.0, 180.0, 50.0), tags: [RenderViewport.twoPane], actions: [tap], label: "测试", textDirection: ltr) (with SemanticsOwner#6a4ce) tried to set a non-finite rect.
'package:flutter/src/semantics/semantics.dart':
Failed assertion: line 1175 pos 12: 'value.isFinite'
Im looking into using this KEYBOARD plugin to add a close button to the ON SCREEN KEYBOARD for when focus is made on a textfield. Looking at the example code, from what I can see - there is no way to using the existing keyboard that is shown in iOS or Android ? You have to create your own customised keyboard and register this ? is this correct ? Ideally I just want to overlay the on screen keyboard with something like an Input Accessory View in iOS which I was hoping this plugin would provide.
按指引,Step2 注册键盘,并且添加了KeyboardRootWidget
:
void main() {
CxyCarNumberKeyboard.registerRegion();
CxyCarNumberKeyboard.registerCharacter();
CxyCarNumberKeyboard.registerNumber();
runApp(KeyboardRootWidget(child: MyApp(),));
}
运行自定义键盘工作正常,但在TextField
上长按就会抛出No MaterialLocalizations found
异常,具体见下面详细异常信息:
dependencies:
cool_ui: "^0.5.5"
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞════════════════════════
The following assertion was thrown building
_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#a3566](dirty,
state: _OverlayEntryWidgetState#c8bf6):
No MaterialLocalizations found.
_OverlayEntryWidget widgets require MaterialLocalizations to be
provided by a Localizations widget ancestor.
Localizations are used to generate many different messages,
labels, and abbreviations which are used by the material library.
To introduce a MaterialLocalizations, either use a MaterialApp at
the root of your application to include them automatically, or
add a Localization widget with a MaterialLocalizations delegate.
The specific widget that could not find a MaterialLocalizations
ancestor was:
_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#a3566]
The ancestors of this widget were:
_Theatre
Overlay
MediaQuery
KeyboardMediaQuery
Directionality
KeyboardRootWidget
[root]
Widget creation tracking is currently disabled. Enabling it
enables improved error messages. It can be enabled by passing
`--track-widget-creation` to `flutter run` or `flutter test`.
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Mac OS X 10.15.3 19D76, locale zh-Hans-CN)
• Flutter version 1.18.0-11.1.pre at /Users/peter/Data/flutter
• Framework revision 2738a1148b (13 days ago), 2020-05-13 15:24:36 -0700
• Engine revision ef9215ceb2
• Dart version 2.9.0 (build 2.9.0-8.2.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/peter/Data/Android/sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /Users/peter/Data/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
查阅相关资料,说是main方法中runApp的顶级widget必须是返回继承自 StatelessWidget
的MaterialApp
,但我按这样调整为如下代码:
void main() {
CxyCarNumberKeyboard.registerRegion();
CxyCarNumberKeyboard.registerCharacter();
CxyCarNumberKeyboard.registerNumber();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: KeyboardRootWidget(child: MyAppContent(),),
);
}
}
结果长按不会出错了,但Android测试自定义键盘是正常的,iOS却经常在TextField
获取到焦点时无法弹出自定义键盘。
How can I create a normal keyboard not the Numeric one?
I need basically the default android one without emojis, microfon, and others
So:
A-z 0-9 and special chars (and accents)
like here:
https://images.techhive.com/images/article/2014/12/android_typing_tips_accent-100538029-orig.jpg
it is enough to set "a", and "á", or "e" or "é"
thanks
也就是去掉时间控制,常显。隐藏由用户按照自己的业务逻辑自己控制。
大哥这种东西就不要往仓库放了,污染了
WidgetUtil这类 和ScreenUtil这个 引用哪个包,谢谢
一个页面两个TextField 2个自定义键盘 高度不同 切换焦点时 会按照上个自定义键盘高度计算高度 导致显示不全或超出
自定义键盘只是个别页面,其它普通页面,都是需要文本输入,先在自定义键盘页面触发输入,再转到普通页面,普通页面的输入框,键盘出来,但输入值不会加到textfield
Congrats! Flutter市集中(pub)唯一能找到的自定义键盘组件.
还没试, 先点赞再使用. 就想问一下. TextFormField 组件中能用吗?
建议提供刻度值控件 时间选择器弹窗控件
一个是普通文本框 一个是自定义键盘的
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'update' was called on null.
Receiver: null
Tried calling: update()
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 CoolKeyboard.openKeyboard (package:cool_ui/keyboards/keyboard_manager.dart:126:16)
#2 CoolKeyboard.interceptorInput.<anonymous closure> (package:cool_ui/keyboards/keyboard_manager.dart:34:13)
<asynchronous suspension>
#3 _DefaultBinaryMessenger.send (package:flutter/src/services/binary_messenger.dart:128:21)
#4 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:309:51)
<asynchronous suspension>
#5 OptionalMethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:424:36)
class CKTextInputType 未重载 bool operator ==(dynamic other) 这个方法,导致 注册键盘 永远只有一个
onTap: () {
Navigator.pushNamed(context, "/newFriend");
return true;
},
如果返回false 路由将不会跳转 如果返回true 路由跳转了 但是没有关闭
Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
#0 Element._debugCheckStateIsActiveForAncestorLookup. (package:flutter/src/widgets/framework.dart:3389:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:3403:6)
#2 Element.ancestorStateOfType (package:flutter/src/widgets/framework.dart:3451:12)
#3 CoolKeyboard.hideKeyboard (package:cool_ui/keyboards/keyboard_manager.dart:174:14)
#4 CoolKeyboard.interceptorInput. (package:cool_ui/keyboards/keyboard_manager.dart:56:11)
#5 _DefaultBinaryMessenger.send (package:flutter/src/services/binary_messenger.dart:128:21)
#6 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:309:51)
#7 OptionalMethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:424:36)
#8 TextInputConnection.close (package:flutter/src/services/text_input.dart:664:32)
#9 EditableTextState._closeInputConnectionIfNeeded (package:flutter/src/widgets/editable_text.dart:1169:28)
#10 EditableTextState.dispose (package:flutter/src/widgets/editable_text.dart:940:5)
#11 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4107:12)
#12 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1737:13)
#13 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#14 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#15 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#16 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#17 Iterable.forEach (dart:core/iterable.dart:277:30)
#18 _RenderDecorationElement.visitChildren (package:flutter/src/material/input_decorator.dart:1467:24)
#19 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#20 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#21 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#22 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#23 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#24 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#25 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#26 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#27 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#28 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#29 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#30 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#31 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#32 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#33 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#34 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#35 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#36 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#37 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#38 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#39 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#40 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#41 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#42 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#43 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#44 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#45 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#46 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#47 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#48 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#49 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#50 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#51 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#52 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#53 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#54 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5181:16)
#55 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#56 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#57 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#58 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#59 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#60 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#61 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#62 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#63 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#64 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#65 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#66 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5181:16)
#67 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#68 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#69 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#70 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#71 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#72 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#73 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#74 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#75 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#76 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#77 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#78 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#79 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#80 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#81 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#82 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#83 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#84 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#85 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#86 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#87 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#88 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#89 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#90 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#91 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#92 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#93 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#94 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#95 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#96 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#97 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#98 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#99 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#100 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#101 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#102 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#103 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#104 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#105 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#106 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#107 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#108 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#109 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#110 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#111 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#112 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#113 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#114 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#115 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#116 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#117 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#118 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#119 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#120 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#121 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#122 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#123 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#124 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#125 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#126 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5181:16)
#127 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#128 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#129 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#130 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#131 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#132 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#133 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#134 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#135 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#136 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#137 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#138 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#139 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#140 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#141 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#142 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#143 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#144 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#145 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#146 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#147 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#148 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#149 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#150 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#151 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#152 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#153 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#154 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#155 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#156 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#157 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#158 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#159 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#160 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#161 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#162 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#163 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#164 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#165 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#166 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#167 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#168 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#169 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#170 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#171 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#172 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#173 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#174 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#175 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#176 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#177 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#178 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#179 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#180 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#181 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#182 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#183 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#184 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#185 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#186 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#187 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#188 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#189 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5181:16)
#190 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#191 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#192 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#193 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#194 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#195 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#196 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#197 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#198 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#199 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#200 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#201 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#202 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#203 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#204 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#205 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#206 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#207 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#208 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#209 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#210 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#211 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#212 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#213 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#214 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#215 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#216 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#217 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#218 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#219 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#220 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#221 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#222 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#223 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#224 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#225 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#226 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#227 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#228 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#229 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#230 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#231 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#232 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#233 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#234 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#235 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#236 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#237 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#238 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#239 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#240 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#241 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#242 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1735:7)
#243 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#244 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#245 ListIterable.forEach (dart:_internal/iterable.dart:39:13)
#246 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1746:25)
#247 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:2426:27)
#248 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2258:15)
#249 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2425:7)
#250 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:702:18)
#251 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
#252 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
#253 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
#254 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
#255 _rootRun (dart:async/zone.dart:1124:13)
#256 _CustomZone.run (dart:async/zone.dart:1021:19)
#257 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#258 _invoke (dart:ui/hooks.dart:236:10)
#259 _drawFrame (dart:ui/hooks.dart:194:3)
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling inheritFromWidgetOfExactType() in the widget's didChangeDependencies() method.
#0 Element._debugCheckStateIsActiveForAncestorLookup. (package:flutter/src/widgets/framework.dart:3389:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:3403:6)
#2 Element.ancestorStateOfType (package:flutter/src/widgets/framework.dart:3451:12)
#3 CoolKeyboard.hideKeyboard (package:cool_ui/keyboards/keyboard_manager.dart:174:14)
#4 CoolKeyboard.interceptorInput. (package:cool_ui/keyboards/keyboard_manager.dart:42:13)
#5 _DefaultBinaryMessenger.send (package:flutter/src/services/binary_messenger.dart:128:21)
#6 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:309:51)
#7 OptionalMethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:424:36)
#8 _TextInputClientHandler._scheduleHide. (package:flutter/src/services/text_input.dart:769:34)
#9 _rootRun (dart:async/zone.dart:1120:38)
#10 _CustomZone.run (dart:async/zone.dart:1021:19)
#11 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#12 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#13 _rootRun (dart:async/zone.dart:1124:13)
#14 _CustomZone.run (dart:async/zone.dart:1021:19)
#15 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#16 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:963:23)
#17 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#18 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
在custom_keyboard.dart页面中,先激活NumberKeyboard.inputType的TextField,随便输入数字,在不点收到键盘,直接退出custom_keyboard.dart页面,然后再次进入页面,NumberKeyboard无法激活键盘。
debug模式下不存在该问题,release打包后会出现,大神帮忙看看啊
你好Kevin,谢谢这个库。
我在很多跟键盘相关的Flutter库看到大家问自定义键盘+TextField的实现方法,我自己也探索了一段时间。为了更有利于世界各地的Flutter开发者使用这个(优秀的)库所以我想PR将键盘用例文档翻译成英文。
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, No such TextInputType: CKNumberKeyboard, null)
使用example中的CustomKeyboardDemo dart文件 焦点到输入框,提示如上错误,弹出键盘没有控制到只显示数字,
环境:D:\my_app\my_app>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17763.864], locale zh-CN)
• Flutter version 1.12.13+hotfix.5 at D:\flutter
• Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:\AndroidSDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = D:\AndroidSDK
• Java binary at: D:\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at D:\Android Studio
• Flutter plugin version 41.0.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[!] IntelliJ IDEA Ultimate Edition (version 2019.3)
• IntelliJ at D:\IDEA20193
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[√] Connected device (1 available)
• MOGOLIA • F2C7N15429014716 • android-arm • Android 6.0 (API 23)
! Doctor found issues in 1 category.
有没有现成的解决方案,如果没有能不能将里面一些做成公用的API,开放给开发者去用?
我们场景:键盘上悬浮TextField,TextField旁边有CupertinoPopoverButton选项,操作CupertinoPopoverButton时遇到了和键盘弹起逻辑有冲突的问题。
如果键盘弹起时TextField失去焦点(正常逻辑),这时候键盘收起,组件下移,但是展开的起点还是键盘收起之前的,所以位置跑偏了;如果键盘弹起时TextField一直在聚焦状态,则键盘不会收起,但是这时候键盘上面的CupertinoPopoverButton展开方向会向下,所以被键盘挡住了。
感觉解决方案有2个:
这个使用场景应该还挺多的。
controller: TextEditingController.fromValue(TextEditingValue( text: '123',))
setState() called after dispose(): KeyboardPageState#abe60(lifecycle state: defunct, not mounted)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.