【お知らせ】みんプロ式Flutter講座は2026年4月末をもって新規販売を終了いたします。詳しくはこちら →
[Flutter]「Don’t import implementation files from another package」の意味と対処法
Flutter(フラッター)のプロジェクトを作る際に、他のパッケージなど、他のDartファイル(ライブラリ)を使うために「import」文を入力すると、
Don’t import implementation files from another package.
という警告と共にimport文の箇所にニョロニョロが表示されることがあります。
これは、他のパッケージ内部で使っている実装用のDartファイルをパッケージ外から直接importしようとする際に発生するようです。
そのような実装用のファイルは、そのパッケージの実装用に使っているファイルであり、パッケージ外から使おうとするとプログラムが壊れてしまう可能性があるため、注意喚起のために警告文を出してくれているようです。
The libraries inside
libare publicly visible: other packages are free to import them. But much of a package’s code is internal implementation libraries that should only be imported and used by the package itself. Those go inside a subdirectory oflibcalledsrc. You can create subdirectories in there if it helps you organize things.You are free to import libraries that live in
lib/srcfrom within other Dart code in the same package (like other libraries inlib, scripts inbin, and tests) but you should never import from another package’slib/srcdirectory. Those files are not part of the package’s public API, and they might change in ways that could break your code.
もし、この警告にも関わらず、今回の動画の例のように使っても大丈夫という確信がある場合は、「Suppress ‘implementation_imports’ warning」を押してやると、ニョロニョロを消すことができます。
(詳しくは、以下の動画で解説してしまうので、よろしければご覧下さい)











