skip to Main Content

How can I access all dependencies on folder packages?

I have try in my pubspec.yaml , but it’s working

packages:
   path: ../package1

Result

enter image description here

2

Answers


  1. You can add it in the dependency part and specify a name.

    dependencies:
      my_local_package:
        path: ../package1
    
    

    And use it as

    import 'package:my_local_package/package1.dart';
    
    Login or Signup to reply.
  2. you can use two ways,upload your package to github and access via it,or local..here are the code for it

    Path dependency

    A Flutter app can depend on a package using a file system path: dependency. The path can be either relative or absolute. Relative paths are evaluated relative to the directory containing pubspec.yaml. For example, to depend on a package, packageA, located in a directory next to the app, use the following syntax:

      dependencies:
      packageA:
        path: ../packageA/
    

    from git

    You can also depend on a package stored in a Git repository. If the package is located at the root of the repo, use the following syntax:

     dependencies:
        packageA:
          git:
            url: https://github.com/flutter/packageA.git
    

    for more info get an idea from this https://docs.flutter.dev/development/packages-and-plugins/using-packages

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search