15

I am new to flutter plugin development, I have read Developing packages & plugins and Writing a good Flutter plugin, but I am confused as a beginner, I have developed Flutter Application based on webview_flutter and a JavaScript library to work offline. I want to extend it as a module or a plugin.

Webview renders some stuff. JavaScript library is being attached from assets.

I am not calling any Platform API directly from my code but my code depends on another plugin.

How do I proceed this? As a plugin or as a module?

Shahzad Akram
  • 4,586
  • 6
  • 32
  • 65
  • 1
    "I want to extend it as a module or a plugin." What does that mean? How can you know you want that if it's not clear to you what a plugin or module even is? A plugin is about making native functionality available to Flutter. A module is about integrating Flutter with an existing native application. Perhaps what you actually want is a reusable Pub package that you can publish to pub.dartlang.org (a plugin is also a Pub package, just a special one that additionally utilizes access to the native platform) – Günter Zöchbauer Feb 17 '19 at 11:47
  • Yes thanks, I want a reuseable Pub package which I want to publish on pub.dartlang org . Now its much clear to me.. – Shahzad Akram Feb 17 '19 at 13:39

2 Answers2

31

A plugin is about making native functionality available to Flutter.
A module is about integrating Flutter with an existing native application.

Perhaps what you actually want is a reusable Pub package that you can publish to pub.dartlang.org (a plugin is also a Pub package, just a special one that additionally utilizes access to the native platform)

See also

A "library package" is a Pub package in contrary to a plain Dart "application package" which is usually not published to pub.dartlang.org.

A pure Dart Pub package (library package) that does not depend on dart:html, dart:ui (Flutter) and is not a Flutter plugin, can be used on any platform (server, command line, Flutter, browser).

If your package has one of the named dependencies, it is limited to a specific platform.

pub.dartlang.org shows labels to categorize published packages accordingly (FLUTTER,WEB,OTHER)

enter image description here

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Hello! Does this mean: if I want to share my special ui widget, it will be a package? – Krahmal Apr 14 '22 at 09:27
  • @Krahmal yes, you need to create a Pub package and publish it to pub.dev. Theoretically it can be used from a Git repo as well, but pub.dev is the usual way. – Günter Zöchbauer Apr 15 '22 at 08:03
10

Flutter plugins:

In short: Native related developments.

Flutter plugin is the wrapper of the native code like android( Kotlin or java) and iOS(swift or objective c). ... Flutter can do anything that a native application can through the use of Platform Channels and Message Passing. Flutter instructs the native iOS/Android code to perform an action and returns the result to Dart.

Flutter packages or modules:

In short: Make the development faster by using code from util libraries.

Flutter supports using shared packages contributed by other developers to the Flutter and Dart ecosystems. This allows quickly building an app without having to develop everything from scratch.

Community
  • 1
  • 1
Googlian
  • 6,077
  • 3
  • 38
  • 44
  • Quick and to the context, other answers are also have positive side. – Alok Vishwakarma Feb 10 '21 at 04:56
  • 1
    A Flutter module is not the same as a Flutter package https://flutter.dev/docs/development/add-to-app/android/project-setup#create-a-flutter-module – David Miguel Jun 30 '21 at 16:06
  • 1
    @DavidMiguel Correct. Flutter package consists of purely dart code and we can integrate in flutter project. Flutter module can integrate in existing android or iOS native app. – MaheshPeri19 Jan 19 '23 at 12:19