Home > Net >  How to import file from lib into file outside of lib in Flutter
How to import file from lib into file outside of lib in Flutter

Time:11-24

I have customised a Flutter package and therefore it's outside of my lib folder.

Structure:

  • project_name
    • lib
      • file.dart
    • package
      • package_file.dart

I want to import file.dart into package_file.dart. How can I achieve this? Tried import 'package:project_name/lib/file.dart' but it says URI not exist.

CodePudding user response:

You should have pubspec.yaml in your package module and declare your project root file packages yaml's dependencies like this :

dependencies:

  ROOT_PROJECT_NAME:
    path: ../../ROOT_PROJECT_NAME
  • Related