US Office

1176 Shadeville Rd, Crawfordville Florida 32327, USA

 +1 (850) 780-1313

India Office

Office No. 501, Shree Ugati Corporate Park, Gandhinagar - 382421, Gujarat, India

[email protected]

How to Add a Package From GitHub In Flutter?

How to Add a Package From GitHub In Flutter

How to Add a Package From GitHub In Flutter?

Earlier we have been through various articles based on flutter How to Print Firestore Timestamp as Formatted Date and Time In Flutter So in this article we will go through how to Add a Package From GitHub In Flutter?

As you develop Flutter applications, you’ll often find the need to incorporate external packages to enhance functionality, save development time, or leverage existing solutions. While many packages are available on, the official package repository for Flutter, there may be cases where you need to add a package directly from GitHub. Adding packages from GitHub allows you to access the latest features, bug fixes, or custom modifications from the package’s repository. In this blog post, we will walk you through a step-by-step guide on how to add a package from GitHub to your Flutter project.

How to Add a Package From GitHub In Flutter?

Example of pubspec.yaml

    sdk: flutter

      url: git://
      ref: master

Example of a file importing the package

import 'package:carousel_pro/src/carousel_pro_widgets.dart';
import 'package:flutter/material.dart';

class NewsCarousel extends StatelessWidget {
  Widget build(BuildContext context) {
    return SizedBox(
      height: 200.0,
      child: WidgetCarousel(
        autoplay: false,
        pages: [],

To make that easier, you can depend directly on a package stored in a Git repository.


The git here says this package is found using Git, and the URL after that is the Git URL that can be used to clone the package.

Even if the package repo is private, if you can connect to the repo using SSH, then you can depend on the package by using the repo’s SSH URL:

    git: [email protected]:munificent/kittens.git

If you want to depend on a specific commit, branch, or tag, add a ref argument:

      url: [email protected]:munificent/kittens.git
      ref: some-branch

The ref can be anything that Git allows to identify a commit.

Git dependency on a package in a folder

The pub tool assumes the package is located at the root of the Git repository. If that is not the case, specify the location with the path argument.

To specify a different location in the repo, use the path argument: For example:

      url: git://
      path: packages/package1

The path is relative to the Git repo’s root. For more details, see Package dependencies.


Hope you enjoyed this article !!!

In this article, we have been through how to add a Package From GitHub in flutter ??

Do not forget to drop your valuable suggestions/feedback. We would love to assist you. is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

Post a Comment