How do I fix: "Error: Dart library 'dart:html' is not available on this platform." in ios/android development Flutter?
Asked Answered
L

0

7

Was testing a UI change on my android emulator with Flutter. Emulator crashed and I got this message:

"Error: Dart library 'dart:html' is not available on this platform. lib/…/pages/sign_up.dart:1 import 'dart:html';"

I also got this message:

FAILURE: Build failed with an exception.

  • Where: Script '/Users/calyxwozniak/dev/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command '/Users/calyxwozniak/dev/flutter/bin/flutter'' finished with non-zero exit value 1

build.gradle says there is an error in my flutterRoot

def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")

Upon looking at others similar questions I have tried: -flutter clean -flutter pub cache repair -flutter pub outdated -deleted and recreated the pubspec.lock folder -updated dependencies Path version -changing minsdkversion in gradle local properties

None of this resolves the error or allows me to run the emulator without it crashing immediately.

Lockyer answered 4/3, 2023 at 0:47 Comment(5)
In sign_up.dart remove the import 'dart:html'; line. Or switch to using: pub.dev/packages/universal_htmlTelex
Are you using the same code file for Flutter Web? if not, then try removing the import statement for "dart: HTML",Irritated
interesting. I didn't put the dart:html import in there, but I have now removed it from sign_up.dart --still getting: Build failed with an exception. * Where: Script '/Users/calyxwozniak/dev/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151. and error underline in flutterRoot def -- Any tips on how to fix this? I can't even find the line of code in flutter.gradle file it's referring toLockyer
please share the error screenshotStet
If this question is solved, delete it and ask a new one.Telex

© 2022 - 2025 — McMap. All rights reserved.