avoid_ web_ libraries_ in_ flutter
                  Don't use web-only libraries outside Flutter web plugins.
Description
#The analyzer produces this diagnostic when a library in a package that isn't a web plugin contains an import of a web-only library:
dart:htmldart:jsdart:js_utildart:js_interopdart:js_interop_unsafepackage:jspackage:web
Example
#
                    When found in a package that isn't a web plugin, the following code
                    produces this diagnostic because it imports dart:html:
                  
import 'dart:html';
import 'package:flutter/material.dart';
class C {}
                      
                      
                      
                    Common fixes
#If the package isn't intended to be a web plugin, then remove the import:
import 'package:flutter/material.dart';
class C {}
                      
                      
                      
                    
                    If the package is intended to be a web plugin, then add the following
                    lines to the pubspec.yaml file of the package:
                  
flutter:
  plugin:
    platforms:
      web:
        pluginClass: HelloPlugin
        fileName: hello_web.dart
                      
                      
                      
                    See Developing packages & plugins for more information.
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.