Juju
Juju

Reputation: 449

How to import file from lib into file outside of lib in Flutter

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

Structure:

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.

Upvotes: 1

Views: 792

Answers (1)

Mojtaba Ghiasi
Mojtaba Ghiasi

Reputation: 983

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

Upvotes: 2

Related Questions