exclude flutter export from import suggestions

143

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';
Share:
143
Code Spirit
Author by

Code Spirit

Updated on December 24, 2022

Comments

  • Code Spirit
    Code Spirit over 1 year

    I often times import cupertino.dart instead of material.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 importing cuppertino.dart so it is not listed in the import suggestions and only use widgets.dart or material.dart instead.

    Is there a way to configure Android Studio or Dart Analyzer to prevent cuppertino.dart to show in suggestions?