gpt4 book ai didi

firebase - 实现 Codelab Firebase 聊天示例

转载 作者:IT王子 更新时间:2023-10-29 07:14:21 29 4
gpt4 key购买 nike

同时根据这个 https://codelabs.developers.google.com/codelabs/flutter-firebase/#8 实现 Firebase for Flutter

我在“使用动画列表”步骤后遇到错误。一切似乎都与教程一致 - Firebase 数据库插件的版本差异是否会导致这种情况?

代码:

new Flexible(
child: new FirebaseAnimatedList(
query: reference,
sort: (a, b) => b.key.compareTo(a.key),
padding: new EdgeInsets.all(8.0),
reverse: true,
itemBuilder: (_, DataSnapshot snapshot, Animation<double> animation) {
return new MessageBubble(
snapshot: snapshot,
animation: animation
);
}
)
),

调试控制台:

I/flutter (17175): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (17175): The following assertion was thrown building PageChatConversation(dirty, state:
I/flutter (17175): PageChatConversationState#e4c10):
I/flutter (17175): type '(BuildContext, DataSnapshot, Animation<double>) => dynamic' is not a subtype of type
I/flutter (17175): 'FirebaseAnimatedListItemBuilder' of 'itemBuilder'
I/flutter (17175):
I/flutter (17175): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (17175): more information in this error message to help you determine and fix the underlying cause.
I/flutter (17175): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (17175): https://github.com/flutter/flutter/issues/new
I/flutter (17175):
I/flutter (17175): When the exception was thrown, this was the stack:
I/flutter (17175): #0 new FirebaseAnimatedList (package:firebase_database/ui/firebase_animated_list.dart:25:20)
I/flutter (17175): #1 PageChatConversationState.build (/data/user/0/com.payitforward.payitforward/cache/pay_it_forwardQZWJQC/pay_it_forward/lib/UI/page_chat_conversation.dart:286:28)
I/flutter (17175): #2 StatefulElement.build (package:flutter/src/widgets/framework.dart:3690:27)
I/flutter (17175): #3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3602:15)
I/flutter (17175): #4 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #5 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #38 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #39 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #40 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #41 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #42 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #43 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #44 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #46 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #47 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #48 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #49 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #50 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #51 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #52 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #53 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #54 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #55 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #56 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #57 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #58 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #59 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #60 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #62 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #63 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4588:14)
I/flutter (17175): #64 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #65 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #66 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #67 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #68 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #69 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #70 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #71 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #72 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #73 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #74 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #75 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #76 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #77 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #78 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #79 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #80 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #81 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #82 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3582:5)
I/flutter (17175): #83 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3718:22)
I/flutter (17175): #84 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3577:5)
I/flutter (17175): #85 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2875:14)
I/flutter (17175): #86 Element.updateChild (package:flutter/src/widgets/framework.dart:2678:12)
I/flutter (17175): #87 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4375:32)
I/flutter (17175): #88 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4703:17)
I/flutter (17175): #89 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #90 _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
I/flutter (17175): #91 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #92 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #93 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #94 StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (17175): #95 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #96 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #97 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #98 ProxyElement.update (package:flutter/src/widgets/framework.dart:3847:5)
I/flutter (17175): #99 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #100 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter (17175): #101 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #102 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #103 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #104 StatefulElement.update (package:flutter/src/widgets/framework.dart:3737:5)
I/flutter (17175): #105 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #106 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter (17175): #107 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #108 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4595:14)
I/flutter (17175): #109 Element.updateChild (package:flutter/src/widgets/framework.dart:2667:15)
I/flutter (17175): #110 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3613:16)
I/flutter (17175): #111 Element.rebuild (package:flutter/src/widgets/framework.dart:3463:5)
I/flutter (17175): #112 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2210:33)
I/flutter (17175): #113 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:612:20)
I/flutter (17175): #114 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter (17175): #115 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:931:15)
I/flutter (17175): #116 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:871:9)
I/flutter (17175): #117 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:783:5)
I/flutter (17175): #118 _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:120)
I/flutter (17175): #119 _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:109)
I/flutter (17175): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (17175): Another exception was thrown: type '(BuildContext, DataSnapshot, Animation<double>) => dynamic' is not a subtype of type 'FirebaseAnimatedListItemBuilder' of 'itemBuilder'
I/FlutterActivityDelegate(17175): onResume setting current activity to this
E/FirebaseInstanceId(17175): Token retrieval failed: AUTHENTICATION_FAILED
W/IInputConnectionWrapper(17175): reportFullscreenMode on inexistent InputConnection
I/FlutterActivityDelegate(17175): onResume setting current activity to this

有什么见解吗?提前致谢!

最佳答案

缺少index参数

typedef Widget FirebaseAnimatedListItemBuilder(
BuildContext context,
DataSnapshot snapshot,
Animation<double> animation,
int index,
);

像这样添加

itemBuilder: (_, DataSnapshot snapshot, Animation<double> animation, _) {

(添加了 ,_)应该可以修复错误。

关于firebase - 实现 Codelab Firebase 聊天示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48421889/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com