- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在我们现在正在编写的应用程序中,我们遇到了一个问题,即如果将焦点放在底部工作表中的文本字段,键盘会在短暂的闪烁后消失。
在尝试修复它数小时后,我试图隔离这种奇怪的行为并提出了以下错误:
如果我在不是主页的页面的脚手架的底部工作表中点击 TextField,键盘就会消失。 (见示例)
我已经在 https://github.com/flutter/flutter/issues/36271 上发布了这个但还没有得到回应。
有人知道吗?这真的是一个错误还是我在路线上做错了什么?
提前致谢。马库斯
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: {
'secondPage': (_) => SecondPage(),
},
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('it does work here'),
),
body: Center(
child: FlatButton(
onPressed: () => Navigator.of(context).pushNamed('secondPage'),
child: Container(
width: 123,
height: 23,
color: Colors.red,
child: Text(
'2nd Page',
textAlign: TextAlign.center,
),
)),
),
bottomSheet: Container(
width: double.infinity,
color: Colors.lightGreen,
height: 90,
child: Center(child: Container(width: 200, child: TextField())),
),
);
}
}
class SecondPage extends StatefulWidget {
SecondPage({Key key}) : super(key: key);
@override
_SecondPageState createState() => _SecondPageState();
}
class _SecondPageState extends State<SecondPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('it does not work here'),
),
bottomSheet: Container(
width: double.infinity,
color: Colors.lightGreen,
height: 90,
child: Center(child: Container(width: 200, child: TextField())),
),
);
}
}
在底部工作表中为容器提供全局键会强制键盘保持事件状态,但随后 Ios 上会出现红色屏幕闪烁,我收到以下错误:
I/flutter (15864): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (15864): The following assertion was thrown while finalizing the widget tree:
I/flutter (15864): Duplicate GlobalKey detected in widget tree.
I/flutter (15864): The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of
I/flutter (15864): the widget tree being truncated unexpectedly, because the second time a key is seen, the previous
I/flutter (15864): instance is moved to the new location. The key was:
I/flutter (15864): - [GlobalKey#06a16]
I/flutter (15864): This was determined by noticing that after the widget with the above global key was moved out of its
I/flutter (15864): previous parent, that previous parent never updated during this frame, meaning that it either did
I/flutter (15864): not update at all or updated before the widget was moved, in either case implying that it still
I/flutter (15864): thinks that it should have a child with that global key.
I/flutter (15864): The specific parent that did not update after having one or more children forcibly removed due to
I/flutter (15864): GlobalKey reparenting is:
I/flutter (15864): - _InheritedResetNotifier
I/flutter (15864): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter (15864):
I/flutter (15864): When the exception was thrown, this was the stack:
I/flutter (15864): #0 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2485:15)
I/flutter (15864): #1 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2510:8)
I/flutter (15864): #2 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:702:18)
I/flutter (15864): #3 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
I/flutter (15864): #4 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
I/flutter (15864): #5 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
I/flutter (15864): #6 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
I/flutter (15864): #10 _invoke (dart:ui/hooks.dart:236:10)
I/flutter (15864): #11 _drawFrame (dart:ui/hooks.dart:194:3)
I/flutter (15864): (elided 3 frames from package dart:async)
I/flutter (15864): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/HwSecImmHelper(15864): mSecurityInputMethodService is null
I/flutter (15864): Another exception was thrown: Duplicate GlobalKey detected in widget tree.
class SecondPage extends StatefulWidget {
SecondPage({Key key}) : super(key: key);
@override
_SecondPageState createState() => _SecondPageState();
}
class _SecondPageState extends State<SecondPage> {
static final Key _key = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('it does not work here'),
),
bottomSheet: Container(
key: _key,
width: double.infinity,
color: Colors.lightGreen,
height: 90,
child: Center(child: Container(width: 200, child: TextField())),
),
);
}
}
dynClient36:flutter_app mhein$ flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.3, on Mac OS X 10.14.5 18F132, locale de-DE)
• Flutter version 1.7.8+hotfix.3 at /Users/mhein/Documents/flutter
• Framework revision b712a172f9 (8 days ago), 2019-07-09 13:14:38 -0700
• Engine revision 54ad777fd2
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/mhein/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• CocoaPods version 1.7.0
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 37.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] VS Code (version 1.36.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0
[✓] Connected device (2 available)
• ONEPLUS A6003 • 89a98b7a • android-arm64 • Android 9 (API 28)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• No issues found!
最佳答案
一种魔法,但是当你保持底部工作表处于状态时,它就起作用了:
class _SecondPageState extends State<SecondPage> {
final _bottomSheet = Container(
color: Colors.lightGreen,
height: 90,
child: Center(child: Container(width: 200, child: TextField())),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('it does not work here'),
),
bottomSheet: _bottomSheet,
);
}
}
当我注意到 build
方法在 TextField
激活时被调用两次时,我明白了。
更新:
在我看来,保持 BottomSheet 处于状态有助于保持对输入字段的关注。如果没有这个技巧,当小部件由于键盘打开而第二次重绘时,输入字段失去焦点并且键盘关闭。问题仍然存在 - 为什么当路由器堆栈为空时不会发生焦点丢失?
关于flutter - 如果 Open Keyboard 的 Textfield 位于命名 Route 的 bottomSheet 中,则 Open Keyboard 意外关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57071575/
我有基于角度 Material 文档的以下代码: 在我的 HTML Abrir BottomSheet 并且,在我的页面 ts 存档中: import { Component, OnInit } f
我想要一些关于如何修改这段代码的帮助,这样我就可以用触摸手势上下滑动这个反应本机底片。我想出了怎么用纽扣来做。在我的Package.json中,我使用了@Gorhom/Bottom-Sheet,“re
我正在为我的一种布局使用 BottomSheet View 。对于一个非常具体的情况,我需要 BottomSheet 的动画持续时间,它通过 setState(...) 方法在布局中滑动。它应该在 4
FAB BottomSheet按下后出现在屏幕上,但是位置不对(见图1),我想做成图2的样子,怎么解决? 我的 Activity : public class FirstscreenActivity
我有一个包含产品详细信息卡片的 BottomSheet。问题是,当我在 Bottom Sheet 处于 展开 状态时单击产品详细信息上的 + 或 - 按钮时,它跳下来。 当它处于关闭状态并且我单击按钮
我正在尝试在我的应用程序中实现 BottomSheet。我正在学习安卓。我已经按照图书馆页面 here 中给出的说明实现了它.我使用了如下的 Java 代码。 findViewById(R.id.bu
我是 Android 的新手 BottomSheet并且我已经成功地尝试了有关如何使用它的示例,但大多数示例仅演示了通过查看点击事件显示/隐藏 BottomSheet。 现在我有以下代码: Botto
我正在使用 bottomsheetlayout 弹出窗口进行社交媒体共享。现在的问题是,它不止一次开放。请帮我解决这个问题。 在我的按钮上单击我调用 asynctask 以下载图像。 @Overrid
我试图不让 BottomSheet 填充整个屏幕,而是在展开时在上方留出一些空间。这是我的 onExpand 填充整个屏幕的代码。 bottomSheetBehavior = BottomSheetB
我有一个 FrameLayout (teaserContainer) 和 BottomSheet (invitesContainer)。 FrameLayout 位于 BottomSheet 之外(和
我一直在尝试设置 Bottomsheet Google 在他们的应用程序(例如 GOOGLE NEWS 等)中使用的方式, This is how Google's Bottomsheet looks
我正在尝试在 Android 中实现类似于下图的摘要 Bottom Sheet 库。有没有什么方法可以将多个 Bottom Sheet 附加到一个 View ,您可以向左/向右滑动以切换并让相邻的 V
目前我正在使用来自 this lib 的底页,我想实现这样的图片动画google map在滑动 bottomsheet 时,我想按照显示的图像一起滑动 imageview,我已经用过这个link fo
我有一个 Bottom Sheet ,里面有一个 NestedScrollView(见下文)。当我按下 FAB 按钮时,我想让这个 NestedScrollView 中的某些部分不可见。但是,当我将一
我正在尝试在布局中使用 BottomSheet。 Root View 是一个 CoordinatorLayout,我想在 Bottom Sheet 的顶部设置 Elevation,所以我将它设置为高值
编辑: package com.walkindeep.teammanagerpreview; import android.content.Context; import android.os.Bun
我遇到 BottomSheetBehaviour 的问题。BottomSheet 在开始时没有扩展到最大高度。但是,它可以滚动到最大高度。但我不想滚动,而是希望 BottomSheet 扩展到其最大高
所以我在 CoordinatorLayout 中使用嵌套子滚动的新支持库行为,我有这样的 View : 我的应用程序有一个要求,这不是新要求,我需要暂时禁用协调器布局的某些元素的滚动。对于这个 b
我已经使用 NestedScrollView 实现了 Bottom Sheet 行为。并且想知道是否可以在外部触摸时隐藏底部 View 。 最佳答案 我终于可以做到了, 使用了以下代码行: @Over
我知道可以像这样设置普通的底板 rememberModalBottomSheetState( initialValue = ModalBottomSheetValue.Hidden, conf
我是一名优秀的程序员,十分优秀!