'Dart 2.17 has warning when using code snipplet

enter image description here

enter image description here

enter image description here

I just update dart sdk to 2.17 and when I use snipplet (in VScode) to auto generate code for Stateless/Stateful it auto import these two package.

But it tell me warning Don't import implementation files from another package. Is this normal?



Solution 1:[1]

Why are you importing implementation files from Flutter? If you have Flutter setup right you do not need to import anything like this.

Solution 2:[2]

You're importing files from a package's src directory. That is not normal. You're directly importing a package's internal, private files.

The analysis warning tells you the name of the warning (implementation_imports), and your IDE should allow you to click on it to get more details:

https://dart.dev/tools/linter-rules#implementation_imports

Instead use:

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SemBauke
Solution 2 jamesdlin