Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Error Undefined class 'RenderContext'

I am having trouble running a Flutter project that was previously working fine with a different person. Specifically, I am encountering an error related to the RenderContext class. The error message I am seeing is: 'Undefined class 'RenderContext' (undefined_class at [path to my file]:[line number]).'

I am using IntelliJ as my environment for this project, and this is my first time using IntelliJ with Flutter. I have tried to use Android Studio to solve this problem.

However, I am still encountering the same error message related to RenderContext. I suspect that there may be a configuration or setup step in IntelliJ that I may have missed.

Can you please offer any suggestions or guidance on how to resolve this issue and get my project running again in IntelliJ? Thank you for your assistance!

The Error

Running Gradle task 'assembleDebug'...

  - ../../../../AppData/Local/Pub/Cache/hosted/pub.dev/universal_html- 
  2.2.2/lib/src/html/dom/element_subclasses.dart:2752:30: Error: The argument type 
'String?' can't be assigned to the parameter type 'Object' because 'String?' is nullable and 'Object' isn't.
  'Object' is from 'dart:core'.
   final parsed = css.parse(text);
                         ^
  - lib/view/screens/location/widget/web_landing_page.dart:268:51: Error: 'RenderContext' isn't a type.
                      onLinkTap: (String url, RenderContext context, Map<String, String> attributes, element) {
                                              ^^^^^^^^^^^^^
  - lib/view/screens/location/widget/web_landing_page.dart:268:38: Error: The argument type 'Null Function(String, invalid-type, Map<String, String>, 
    dynamic)' can't be assigned to the parameter type 'void Function(String, Map<String, String>, Element)'.
   'Map' is from 'dart:core'.
   'Element' is from 'package:html/dom.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dev/html-0.15.4/lib/dom.dart').
                      onLinkTap: (String url, RenderContext context, Map<String, String> attributes, element) {
                                 ^
  - lib/view/screens/html/html_viewer_screen.dart:111:57: Error: 'RenderContext' isn't a type.
                            onLinkTap: (String url, RenderContext context,
                                                    ^^^^^^^^^^^^^
  - lib/view/screens/html/html_viewer_screen.dart:108:31: Error: The method 'SelectableHtml' isn't defined for the class '_HtmlViewerScreenState'.

    -'_HtmlViewerScreenState' is from 'package:alqalaf/view/screens/html/html_viewer_screen.dart' ('lib/view/screens/html/html_viewer_screen.dart').

  Try correcting the name to the name of an existing method, or defining a method named 'SelectableHtml'.
                        : SelectableHtml(
                          ^^^^^^^^^^^^^^
  Target kernel_snapshot failed: Exception


  FAILURE: Build failed with an exception.

Run Errors

Dart Analysis

like image 504
Esraa Gamal Avatar asked May 29 '26 14:05

Esraa Gamal


1 Answers

Probably because html package version, the newer version has removed RenderContext, you can try removing the ^ symbol in the pubspec.yaml file.

example: flutter_html: ^3.0.0-alpha.6 to flutter_html: 3.0.0-alpha.6

like image 165
John Henry Avatar answered Jun 01 '26 07:06

John Henry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!