Flutter › Custom Widgets & Reusable Components

How can you publish and share a custom widget library as its own separate, versioned internal package, letting multiple different Flutter apps within an organization reuse the exact same set of components?

Advanced

Answer

Once a custom widget library has matured and proven genuinely useful across a specific app, extracting it into its own separate, independently versioned Dart or Flutter package allows multiple entirely different apps developed within the same organization to depend on and reuse that exact same shared set of components, and this can be published either privately, such as through a private package repository or a private git repository referenced with a specific version constraint, or publicly on pub.dev, ensuring every app within the organization stays visually and behaviorally consistent while also making future improvements to the shared library immediately available to every consuming app simply by updating a version number.
# pubspec.yaml, referencing a private shared widget library
dependencies:
  company_design_system:
    git:
      url: https://github.com/company/design-system.git
      ref: v2.3.0
Real-world example A large company with several separate Flutter apps extracts their shared button, card, and input field widgets into one internal design system package, ensuring visual consistency across all of their apps while letting a single centralized team maintain and continuously improve that shared component library.

Common follow-ups: What versioning strategy should be used when publishing internal updates to a shared widget package?;What is the difference between publishing a package privately versus publicly on pub.dev?