multiple_combinators
Using multiple 'hide' or 'show' combinators is never necessary and often produces surprising results.
Description
#The analyzer produces this diagnostic when an import or export directive contains more than one combinator.
Examples
#The following code produces this diagnostic because the second show
combinator hides List
and int
:
import 'dart:core' show Future, List, int show Future;
var x = Future.value(1);
The following code produces this diagnostic because
the second hide
combinator is redundant:
import 'dart:math' hide Random, max, min hide min;
var x = pi;
The following codes produce this diagnostic because
the hide
combinator is redundant:
import 'dart:math' show Random, max hide min;
var x = max(0, 1);
var r = Random();
The following code produces this diagnostic because
the show
combinator already hides Random
and max
,
so the hide
combinator is redundant:
import 'dart:math' hide Random, max show min;
var x = min(0, 1);
Common fixes
#If you prefer to list the names that should be visible,
then use a single show
combinator:
import 'dart:math' show min;
var x = min(0, 1);
If you prefer to list the names that should be hidden,
then use a single hide
combinator:
import 'dart:math' hide Random, max, min;
var x = pi;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。