Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run flutter_markdown example #6147

Closed
jimmyshiau opened this issue Sep 30, 2016 · 4 comments · Fixed by #6176
Closed

Unable to run flutter_markdown example #6147

jimmyshiau opened this issue Sep 30, 2016 · 4 comments · Fixed by #6176

Comments

@jimmyshiau
Copy link

jimmyshiau commented Sep 30, 2016

Steps to Reproduce

Run flutter run -v with flutter_markdown example (Nexus 7 (2013) Android 4.4.4)
https://github.com/flutter/flutter/blob/master/packages/flutter_markdown/example/demo.dart

It will show error
screenshot_2016-09-30-16-44-15

Flutter Doctor

[✓] Flutter (on Mac OS, channel unknown)
• Flutter at /usr/local/flutter/flutter
• Framework revision 8a82332 (17 hours ago), 2016-09-29 08:59:43
• Engine revision 3551e7a
• Tools Dart version 1.20.0-dev.5.0

[✓] Android toolchain - develop for Android devices (Android SDK 24.0.2)
• Android SDK at /Users/jimmy/Library/Android/sdk
• Platform android-24, build-tools 24.0.2
• Java(TM) SE Runtime Environment (build 1.8.0_45-b14)

[✓] iOS toolchain - develop for iOS devices (Xcode 8.0)
• XCode at /Applications/Xcode.app/Contents/Developer
• Xcode 8.0, Build version 8A218a

[✓] Atom - a lightweight development environment for Flutter
• flutter plugin version 0.2.5
• dartlang plugin version 0.6.39

[✓] Connected devices
• Nexus 7 • 0874da9c • android-arm

Logs and Crash Reports

  29 ms • I/flutter : ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
   2 ms • I/flutter : The following assertion was thrown building RawGestureDetector([GlobalKey 587447520]; state:
   0 ms • I/flutter : RawGestureDetectorState(127753856; gestures: vertical drag; behavior: opaque)):
   0 ms • I/flutter : inheritFromWidgetOfExactType(Theme) was called before _MarkdownBodyRawState.initState() completed.
   0 ms • I/flutter : When an inherited widget changes, for example if the value of Theme.of() changes, its dependent
   0 ms • I/flutter : widgets are rebuilt. If the dependent widget's reference to the inherited widget is in a constructor
   0 ms • I/flutter : or an initState() method, then the rebuilt dependent widget will not reflect the changes in the
   0 ms • I/flutter : inherited widget.
   0 ms • I/flutter : Typically references to to inherited widgets should occur in widget build() methods. Alternatively,
   4 ms • I/flutter : initialization based on inherited widgets can be placed in the dependenciesChanged method, which is
2295 ms • I/flutter : called after initState and whenever the dependencies change thereafter.
  70 ms • I/flutter : When the exception was thrown, this was the stack:
   0 ms • I/flutter : #0      StatefulElement.inheritFromWidgetOfExactType.<anonymous closure> (package:flutter/src/widgets/framework.dart:2827:9)
   0 ms • I/flutter : #2      StatefulElement.inheritFromWidgetOfExactType (package:flutter/src/widgets/framework.dart:2825:12)
   0 ms • I/flutter : #3      Theme.of (package:flutter/src/material/theme.dart:43:27)
   0 ms • I/flutter : #4      MarkdownBody.createDefaultStyle (package:flutter_markdown/src/markdown.dart:90:53)
   0 ms • I/flutter : #5      _MarkdownBodyRawState._buildMarkdownCache (package:flutter_markdown/src/markdown_raw.dart:156:69)
   2 ms • I/flutter : #6      _MarkdownBodyRawState.initState (package:flutter_markdown/src/markdown_raw.dart:135:5)
   0 ms • I/flutter : #7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:2761:14)
   0 ms • I/flutter : #8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:2647:5)
   0 ms • I/flutter : #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2139:14)
   0 ms • I/flutter : #10     Element.updateChild (package:flutter/src/widgets/framework.dart:1970:12)
   0 ms • I/flutter : #11     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:3436:14)
   0 ms • I/flutter : #12     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2139:14)
   0 ms • I/flutter : #13     Element.updateChild (package:flutter/src/widgets/framework.dart:1970:12)
   0 ms • I/flutter : #14     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:3436:14)
   0 ms • I/flutter : #15     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2139:14)
   0 ms • I/flutter : #16     Element.updateChild (package:flutter/src/widgets/framework.dart:1970:12)
   0 ms • I/flutter : #17     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:3436:14)
@abarth
Copy link
Contributor

abarth commented Sep 30, 2016

Thanks for the report! We added this assert to catch bugs and it looks like the markdown example has an instance of this bug.

/cc @Hixie

@abarth abarth added the ⚠ bug label Sep 30, 2016
@Hixie
Copy link
Contributor

Hixie commented Oct 2, 2016

also cc @HansMuller who added this assert.

My guess is that to fix this we just have to move the call to _buildMarkdownCache from initState to dependenciesChanged in this file:
https://github.com/flutter/flutter/blob/master/packages/flutter_markdown/lib/src/markdown_raw.dart

@HansMuller
Copy link
Contributor

See also: #6166

@github-actions
Copy link

github-actions bot commented Sep 5, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants