avoid-web-libraries-in-flutter
Same as avoid_web_libraries_in_flutter in Dart lints
- Group
- Correctness
- Path
lint/correctness/avoid-web-libraries-in-flutter- Default
- On (recommended)
- Origin
- Dart lints
- Domain
- flutter
- Rule
- 188 of 512
Disallow importing web-only dart: libraries from Flutter code.
Applies only to packages depending on Flutter, excluding Flutter web plugins.
The legacy dart:html, dart:js, and dart:js_util imports are checked;
modern JS interop libraries are allowed by the upstream lint.
Invalid
// Bad: imports of web-only dart libraries.
import 'dart:html';
import 'dart:js';
import 'dart:js_util';
void main() {}// Bad: imports of web-only dart libraries.import 'dart:html';import 'dart:html';import 'dart:js';import 'dart:js';import 'dart:js_util';Valid
// Good: portable imports with no web-only libraries.
import 'dart:async';
import 'dart:convert';
import 'dart:math';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
void main() {}Configure avoid-web-libraries-in-flutter
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"correctness": {
"avoid-web-libraries-in-flutter": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/correctness/avoid-web-libraries-in-flutter: <reason>More correctness rules
- await-only-futures
await_only_futuresrecommendedAwait only values assignable to futures;
FutureOr, dynamic, bottom types and extension types are accepted like the analyzer. - banned-importscross-file
Report imports forbidden by package-relative architectural boundaries.
- cancel-subscriptions
cancel_subscriptionsrecommendedCancel instances of
dart:asyncStreamSubscription. - check-is-not-closed-after-async-gaprecommendedbloc
Flags Bloc
addandemitcalls after an await without a freshisClosedcheck. - close-sinks
close_sinksrecommendedClose instances of
dart:coreSink. - collection-methods-unrelated-type
collection_methods_unrelated_typerecommendedReports collection lookups whose argument type is unrelated to the collection's type argument.
- comment-references
comment_referencesrecommendedFlags doc-comment references
[name]that resolve to nothing in scope. - correct-order-for-super-dispose
correct_order_for_super_disposerecommendedflutterRequire
super.dispose()to be the last call indispose.