exclude flutter export from import suggestions
Solution 1
Seems no, but there is a workaround: You can write a linter to examine your code and warn (or error) whenever you see imports of cupertino.dart
. That linter can even automatically correct the code (by replacing cupertino with material).
Some methodology thoughts: I often want something to be automatically performed ("import material not cupertino" in your case); but later I realized it is hard or not exist yet, but some verifier is good enough ("manually import; but warn if you import the wrong one").
Solution 2
You can create an export file with your exports inside and call this file afterwards.
For example create an exportsFile
:
export 'package:flutter/material.dart';
And now call this file when you wants:
import 'exportsFile.dart';
Code Spirit
Updated on December 24, 2022Comments
-
Code Spirit over 1 year
I often times import
cupertino.dart
instead ofmaterial.dart
when having to import widgets because its the first suggested options. Its not a real problem but for the sake of consistency I want to prevent importingcuppertino.dart
so it is not listed in the import suggestions and only usewidgets.dart
ormaterial.dart
instead.Is there a way to configure Android Studio or Dart Analyzer to prevent
cuppertino.dart
to show in suggestions?