Flutter Packages

Pre-Requirements

Flutter installed on device.

Creating a Flutter Package

  1. Create a package

  2. Implement the package

  3. Test your plugin

  4. Adding Documentation

  5. API Documentation

  6. Adding license to the LICENSE file

  7. Publishing your package

  8. Handling package interdependencies

Adding Package to a Flutter Project

https://flutter.dev/docs/development/packages-and-plugins/using-packages

Reference: adding-packages-in-flutter-app

Updating Flutter Project Package Dependencies

Updating Flutter Packages (Plugins) Automatically

  1. Run Pub Outdated

  2. Run $ flutter pub upgrade --major-versions This will update the pubspec.yaml file for you.

  3. Review and resolve your dart code for outdated methods.

Updating Flutter Packages (Plugins) Manually

Use $ flutter pub deps to view dependency tree.

  1. Update to the latest stable dart version by updating the Android Studio Dart Plugin

  2. in the terminal run $ dart --version to get the installed version of dart.

     <Repository Path>$ dart --version
     Dart SDK version: 2.12.1 (stable) (Wed Mar 10 10:18:47 2021 +0100) on "linux_x64"
     <Repository Path>$    
    
  3. For each Flutter Package view the versions and select the flutter package based on the Min Dart SDK.

    Choose a version that has the same first digit build number.

    Example: installed dart is 2.12.01 (stable) so choose packages that support Min dart SDK of 2.0.0

    Choosing the lowest version and adding the ^ allows the compiler to determine a compatible version (this is called Version Solving).

  4. Run Pub upgrade and resolve any package version issue messages

From GitHub

Reference: How to modify an existing pub package to use in your flutter project

  1. Find the repository on GitHub

  2. Fork the repository

  3. Commit and push changes

  4. Add repository as a flutter pubspec yaml depencency

dependencies:
  flutter:
    sdk: flutter

  [package-name]:
    git:
      url: https://github.com/[git-username]/[git-repository-name]

From Flutter pub.dev, or local package

From Local Directory

Journal