当我试图从URL加载PDF时,我得到了错误。它显示PDF的页数,但随后崩溃。
使用插件-https://pub.dev/packages/advance_pdf_viewer
════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (28488): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (28488): The following assertion was thrown while rebuilding dirty elements:
I/flutter (28488): 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4371 pos 14:
I/flutter (28488): 'owner!._debugCurrentBuildTarget == this': is not true.
I/flutter (28488):
I/flutter (28488): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (28488): more information in this error message to help you determine and fix the underlying cause.
I/flutter (28488): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (28488): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (28488):
I/flutter (28488): The relevant error-causing widget was:
I/flutter (28488): PDFViewer
I/flutter (28488):
lib/…/panSignatureScreens/pan_screen.dart:156
I/flutter (28488):
I/flutter (28488): When the exception was thrown, this was the stack:
I/flutter (28488): #2 Element.rebuild.<anonymous closure>
package:flutter/…/widgets/framework.dart:4371
I/flutter (28488): #3 Element.rebuild
package:flutter/…/widgets/framework.dart:4374
I/flutter (28488): #4 BuildOwner.buildScope
package:flutter/…/widgets/framework.dart:2777
I/flutter (28488): #5 WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:906
I/flutter (28488): #6 RendererBinding._handlePersistentFrameCallback
package:flutter/…/rendering/binding.dart:309
I/flutter (28488): #7 SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1117
I/flutter (28488): #8 SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1055
I/flutter (28488): #9 SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:971
I/flutter (28488): #13 _invoke (dart:ui/hooks.dart:251:10))
I/flutter (28488): #14 _drawFrame (dart:ui/hooks.dart:209:3))
我的用法-在列中(children:[])
new Expanded(
child: Container(
child: PDFViewer(
document: document,
),
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
),
),
),
9条答案
按热度按时间vdgimpew1#
我遇到了同样的问题,问题是我调用了同一个类中的类。使用另一个小部件替换它解决了这个问题。
ycggw6v22#
我刚刚犯了一个类似的错误:
这可能是另一个原因,因为我得到了一个stackoverflow,但我的答案将有望帮助其他人谁搜索这个错误消息。
我的问题是,我做了一个返回自身示例的小部件(我命名了两个相同的类):
我通过简单地重命名一个类来解决它。
odopli943#
对我来说,当我在
CustomScrollView
中使用一个小部件而不是slip时,这种情况就发生了v8wbuo2f4#
如果仍然有人得到这个错误,我解决了我的添加
WidgetsFlutterBinding.ensureInitialized()before runApp function.
nvbavucw5#
如果您使用的是Hive(https://pub.dev/packages/hive),则可能是因为在调用
await Hive.openBox<T>("boxName")
时使用了错误的类型T
。(Took我这么长时间才弄清楚,所以希望这可以保存你一些时间,甚至可能对未来的我lol)
fruv7luv6#
我的问题:我有两个同名的类。删除其中一个解决了我的问题??
3gtaxfhh7#
您是否正在使用FirebaseMessaging?如果是,可能是advance_pdf_viewer与FirebaseMessaging的onBackgroundMessage冲突。
sr4lhrrt8#
是!只有在使用Firebase Cloud Messaging Service的后台消息处理程序时,才会与
advance_pdf_viewer
发生冲突。例如,如果你有这样的东西:
注解以下代码和/或在定位器/其他视图中配置通知:
Ps:
PushNotificationsHandler
是另一个类。aoyhnmkz9#
我通过更改一个Stateless小部件的名称解决了这个问题。
要非常小心,而使您的小部件的名称,如果你使任何两个小部件具有相同的名称无意识地那么你会得到这种类型的错误.
请确保分配与之相关的小部件的名称,这样你就不会得到这种类型的错误。