Currently trying to run an example of a guitar tuner created with the 'flutter_fft' plugin, however, I'm receiving an error on some of my imports. I can see that all of these files exist inside my flutter folder but can't seem to access them?
Here are my imports and the error I am receivingmy imports and the error I am receiving
But as you can see in this screenshot I do have all of those files available somewhere on my PC, and the material.dart import works fine?
I've been trying to work this out for a while but after asking a question here the other day and getting an almost immediate, and extremely helpful response, I've decided to come here again. Thanks in advance.
CodePudding user response:
When importing from a package (like flutter) you must first specify the package with a package:
and then the path to the imports.
If you don't specify this, dart will assume you are trying to import a file on the same directory as the current file.
so instead of import 'button_style.dart';
it should be import package:flutter/src/material/button_style.dart
.
The above will work, but I will let you know that the sole purpose of importing package:flutter/material.dart;
is to automatically import every file inside the material
directory, and so, all of your imports are useless if you already import material.dart
.