- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在开发一个页面使用 ReorderableListView 小部件的应用程序。向上拖动 Tile 时出现错误,但是当我向下拖动任何 Tile 时它工作正常。该错误与多个小部件使用的全局 key 有关,但所有 key 彼此不同。任何帮助,将不胜感激。提前致谢。附上视频链接和代码以供引用。
class GurmatLekh extends StatefulWidget {
@override
_GurmatLekhState createState() => _GurmatLekhState();
}
Widget listTile(
{ String key, Widget widget, String title}) {
BuildContext context;
return Container(
key: Key(key),
decoration: BoxDecoration(
color: theme == 1 ? Colors.black : Colors.white,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: Colors.lightBlue)),
child: ListTile(
onTap: () => Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => widget)),
title: Text(
title,
style: TextStyle(
color: theme == 0 ? Colors.black : Colors.white,
fontFamily: "GurbaniAkhar",
fontSize: 20.0),
),
));
}
class _GurmatLekhState extends State<GurmatLekh> {
List<Widget> list = [
listTile(key: "1", title: "1", widget: listTile1()),//listTile1 is the next Page.
listTile(key: "2", title: "2", widget: listTile2()),//listTile2 is the next Page.
listTile(key: "3", title: "3", widget: listTile3()),//listTile3 is the next Page.
listTile(key: "4", title: "4", widget: listTile4()),//listTile4 is the next Page.
listTile(key: "5", title: "5", widget: listTile5()),//listTile5 is the next Page.
];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(50, 42, 57, 1.0),
appBar: AppBar(
backgroundColor: Colors.lightBlue,
centerTitle: true,
title: Text(
"gurmiq lyK", //gurmat lekh
style: TextStyle(
fontFamily: "Prabhki",
fontSize: 27.0,
fontWeight: FontWeight.bold),
),
),
body: Stack(children: <Widget>[
Opacity(
opacity: 0.6,
child: Container(
color: Colors.teal,
),
),
ReorderableListView(
children: list,
onReorder: (oldIndex, newIndex) {
print(oldIndex);
print(newIndex);
if (newIndex > list.length) newIndex = list.length;
if (oldIndex < newIndex) newIndex--;
Widget widget = list[oldIndex];
list.remove(widget);
list.insert(newIndex, widget);
setState(() {});
},
),
]));
}
}
Here is the video for my error
这是AS控制台报错
I/flutter ( 6893): The following assertion was thrown building LongPressDraggable<Key>(state:
I/flutter ( 6893): _DraggableState<Key>#a6138):
I/flutter ( 6893): Multiple widgets used the same GlobalKey.
I/flutter ( 6893): The key [GlobalObjectKey ValueKey<String>#c5ac5] was used by multiple widgets. The parents of those
I/flutter ( 6893): widgets were:
I/flutter ( 6893): - Listener(listeners: [down], behavior: deferToChild, renderObject: RenderPointerListener#ef3da
I/flutter ( 6893): relayoutBoundary=up4 NEEDS-LAYOUT)
I/flutter ( 6893): - Listener(listeners: [down], behavior: deferToChild, renderObject: RenderPointerListener#78330
I/flutter ( 6893): relayoutBoundary=up3)
I/flutter ( 6893): A GlobalKey can only be specified on one widget at a time in the widget tree.
I/flutter ( 6893):
I/flutter ( 6893): When the exception was thrown, this was the stack:
I/flutter ( 6893): #0 GlobalKey._debugReserveFor.<anonymous closure> (package:flutter/src/widgets/framework.dart:172:11)
I/flutter ( 6893): #1 GlobalKey._debugReserveFor (package:flutter/src/widgets/framework.dart:190:6)
I/flutter ( 6893): #2 Element.updateChild.<anonymous closure> (package:flutter/src/widgets/framework.dart:2724:13)
I/flutter ( 6893): #3 Element.updateChild (package:flutter/src/widgets/framework.dart:2727:6)
I/flutter ( 6893): #4 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #5 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #6 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #7 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #8 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter ( 6893): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #10 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #11 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #12 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #13 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #14 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter ( 6893): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #18 StatelessElement.update (package:flutter/src/widgets/framework.dart:3781:5)
I/flutter ( 6893): #19 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #20 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4585:32)
I/flutter ( 6893): #21 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4975:17)
I/flutter ( 6893): #22 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #23 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #25 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #26 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #27 ProxyElement.update (package:flutter/src/widgets/framework.dart:3990:5)
I/flutter ( 6893): #28 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #29 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #30 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #31 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #32 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #33 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #35 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #39 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter ( 6893): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #41 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #43 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #44 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #45 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #46 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #47 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter ( 6893): #48 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #49 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #50 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #51 StatelessElement.update (package:flutter/src/widgets/framework.dart:3781:5)
I/flutter ( 6893): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #55 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter ( 6893): #56 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #57 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #58 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #59 StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter ( 6893): #60 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #61 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 6893): #62 Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 6893): #63 StatelessElement.update (package:flutter/src/widgets/framework.dart:3781:5)
I/flutter ( 6893): #64 Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 6893): #65 _LayoutBuilderElement._layout.<anonymous closure> (package:flutter/src/widgets/layout_builder.dart:118:18)
I/flutter ( 6893): #66 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
I/flutter ( 6893): #67 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:107:11)
I/flutter ( 6893): #68 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1730:58)
I/flutter ( 6893): #69 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:799:15)
I/flutter ( 6893): #70 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1730:13)
I/flutter ( 6893): #71 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:205:5)
I/flutter ( 6893): #72 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter ( 6893): #73 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter ( 6893): #74 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter ( 6893): #75 __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:104:13)
I/flutter ( 6893): #76 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter ( 6893): #77 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:510:15)
I/flutter ( 6893): #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1634:7)
I/flutter ( 6893): #79 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:142:11)
I/flutter ( 6893): #80 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:339:7)
I/flutter ( 6893): #81 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:212:7)
I/flutter ( 6893): #82 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:356:14)
I/flutter ( 6893): #83 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1509:7)
I/flutter ( 6893): #84 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:768:18)
I/flutter ( 6893): #85 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:281:19)
I/flutter ( 6893): #86 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:677:13)
I/flutter ( 6893): #87 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter ( 6893): #88 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 6893): #89 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 6893): #90 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 6893): #91 _invoke (dart:ui/hooks.dart:154:13)
I/flutter ( 6893): #92 _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter ( 6893): ════════════════════════════════════════════════════════════════════════════════════════════════════
最佳答案
对于 future 的访客,如果有人遇到同样的问题,那么这很好地解决了我的问题。 Github issue link
我将 onReorder 方法更改为以下方法。基本上我将这个过程延迟了 100 毫秒并且它运行良好。
onReorder: (oldIndex, newIndex) {
if (newIndex > list.length) newIndex = list.length;
if (oldIndex < newIndex) newIndex--;
Future.delayed(Duration(milliseconds: 100), (){
setState(() {
final Widget item = list.removeAt(oldIndex);
list.insert(newIndex, item);
});
});
},
关于android - 可重新排序 ListView :Multiple widgets used the same GlobalKey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54171563/
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
我正在试验 jquery-ui 并查看和克隆一些示例。在一个示例(自动完成的组合框)中,我看到一个带有 ui-widget 类的 anchor (a) 元素,它与包含的 css 文件中的 .ui-wi
在我帮助维护的代码中,我发现了多个如下所示的代码示例: Description := IfThen(Assigned(Widget), Widget.Description, 'No Widget')
这个问题在这里已经有了答案: CSS Performance Question (8 个答案) 关闭 9 年前。 这是一个很常见的情况。假设我们有一些标记: 我们可以使用 2 个选项来
这个问题在这里已经有了答案: CSS: Class name selector- name starts with (2 个答案) 关闭 5 年前。
我有一个布局,其中Row小部件中有两个子部件,这两个都是灵活的小部件。左侧的小部件包含红色和蓝色的小部件,我希望根据右侧小部件的高度增加蓝色小部件的高度(这是一个灵活的小部件,其FLEX值为7)。。例
我有一个布局,其中Row小部件中有两个子部件,这两个都是灵活的小部件。左侧的小部件包含红色和蓝色的小部件,我希望根据右侧小部件的高度增加蓝色小部件的高度(这是一个灵活的小部件,其FLEX值为7)。。例
这是一个代码: import 'package:flutter/material.dart'; import 'package:flutterapp/ui/pages/notes_home.dart'
ListView、GridView、SingleChildScrollView 等小部件是可滚动的小部件,而Container、SizedBox, Column 不是。 有没有办法检查 Widget
假设我在 Python 中有这个简单的函数: def f(gender, name): if gender == 'male': return ranking_male(nam
我不想听起来像个糟糕的新手,但是小部件是独立的应用程序吗?例如,我正在为 Android 创建一个新闻阅读器应用程序,我想要一个主屏幕小部件。我是将小部件创建为 Hook 到其他应用程序的单独项目/应
如何告诉 Tk 小部件告诉我它的子级是什么(或谁,视情况而定)?有这个命令吗? 例如,给定一个带有标签、按钮和其他装饰的 Canvas 小部件 .cvs ...如何查询 Canvas ? 最佳答案 w
我为 Android 开发了一个 APP + 主屏幕小部件。现在我更新了应用程序(增加了版本代码/名称)但是当我安装时,它不会自动替换屏幕上现有的小部件。它只是说“问题加载小部件”。 有什么想法吗??
我是小部件开发的新手..我设法构建了一个无法调整大小的小部件..我希望它像 - 用户设法根据自己调整大小......有人可以告诉我如何制作它可能吗? 谢谢 friend 。 最佳答案 AppWidge
我有一个小部件列表: List widgetList = List(); widgetList.add(WidgetA()); widgetList.add(WidgetB()); widgetLis
对不起,我的英语不好! 我开发了一个今日小部件。我需要从小部件启动 map 应用程序(例如),并且在设备锁定时不工作。在这种情况下如何检测锁定的设备并启动解锁屏幕? 问候, 最佳答案 而不是使用 UI
我正在尝试制作我的小部件的免费版本,我想向小部件添加广告,这可能吗?如果是这样怎么办? 最佳答案 小部件应用程序中的 View 仅限于: 模拟时钟 按钮 天文台 图像按钮 ImageView 进度条
我在 Android Studio 中创建了一个新项目,然后添加了一个新的小部件并在我的 Nexus 5 5.1 上运行该应用程序,它可以工作,但是当尝试将小部件添加到主屏幕时,它没有出现在小部件列表
我有一个字符串 'currentMessage' 和一个用于显示它的标签。我有一个 Toplevel 小部件,其中包含一个文本小部件,为“currentMessage”提供新值: from tkint
我尝试使用这个 link 解决我的问题 update - I figured out that there is something wrong with the setter of the pend
我是一名优秀的程序员,十分优秀!