ponnamkarthik / FlutterHtmlView

Flutter Plugin to render html as a Widget
Apache License 2.0
241 stars 107 forks source link

On using MarkdownStyleSheet: The method 'merge' was called on null #105

Open singh-preet opened 4 years ago

singh-preet commented 4 years ago

Hello, thanks in advance. I am using flutter_html_view plugin to read display blogs. I am getting html data from wordpress api. I am getting 12-13 blogs from the API. All of them are working, except one. When I open that blog, it says "The method 'merge' was called on null ". However, if I remove the stylesheet, I no longer get any error. Below is my code. Please check and help: `class BlogDetails extends StatefulWidget { Map data={}; BlogDetails({this.data}); @override _BlogDetailsState createState() => _BlogDetailsState(); }

class _BlogDetailsState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.data['title']['rendered']), ), body: Padding( padding: const EdgeInsets.all(8.0), child: HtmlView( data: widget.data['content']['rendered'], styleSheet: MarkdownStyleSheet( p: TextStyle(fontSize: 18, color: Colors.black, fontWeight: FontWeight.w300), h1: TextStyle(fontSize: 25, color: Colors.black, letterSpacing: 3), a: TextStyle(color: Colors.blue), strong: TextStyle(fontWeight: FontWeight.w400), blockSpacing: 15, listIndent: 5, ), onLaunchFail: ()=>print('Waheguru'), ), ) ); } }`

parth22 commented 4 years ago

Hello, I am using this same plugin and i'm also getting this same error in dependancy example. Below is my IDE error log.

I/flutter (12893): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (12893): The following NoSuchMethodError was thrown building HtmlView:
I/flutter (12893): The method 'merge' was called on null.
I/flutter (12893): Receiver: null
I/flutter (12893): Tried calling: merge(null)
I/flutter (12893): 
I/flutter (12893): The relevant error-causing widget was:
I/flutter (12893):   HtmlView file:///Users/inblinfotech/Downloads/FlutterHtmlView-master/example/lib/main.dart:51:22
I/flutter (12893): 
I/flutter (12893): When the exception was thrown, this was the stack:
I/flutter (12893): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter (12893): #1      MarkdownBuilder.visitElementBefore (package:flutter_markdown/src/builder.dart:156:28)
I/flutter (12893): #2      Element.accept (package:markdown/src/ast.dart:46:17)
I/flutter (12893): #3      Element.accept (package:markdown/src/ast.dart:49:17)
I/flutter (12893): #4      MarkdownBuilder.build (package:flutter_markdown/src/builder.dart:117:12)
I/flutter (12893): #5      _MarkdownWidgetState._parseMarkdown (package:flutter_markdown/src/widget.dart:117:25)
I/flutter (12893): #6      _MarkdownWidgetState.didChangeDependencies (package:flutter_markdown/src/widget.dart:86:5)
I/flutter (12893): #7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4661:12)
I/flutter (12893): #8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
I/flutter (12893): ...     Normal element mounting (31 frames)
I/flutter (12893): #39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
I/flutter (12893): #40     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5947:32)
I/flutter (12893): ...     Normal element mounting (185 frames)
I/flutter (12893): #225    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
I/flutter (12893): #226    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5947:32)
I/flutter (12893): ...     Normal element mounting (255 frames)
I/flutter (12893): #481    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
I/flutter (12893): #482    Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
I/flutter (12893): #483    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1148:16)
I/flutter (12893): #484    RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1119:5)
I/flutter (12893): #485    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1061:17)
I/flutter (12893): #486    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2607:19)
I/flutter (12893): #487    RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1060:13)
I/flutter (12893): #488    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:941:7)
I/flutter (12893): #489    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:922:7)
I/flutter (12893): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
I/flutter (12893): 
I/flutter (12893): ════════════════════════════════════════════════════════════════════════════════════════════════════