Flutter的四种Build模式(app/module/package/plugin)

333 阅读1分钟

我们知道,通过命令行(flutter create)可以创建 flutter 代码,通过 flutter create -h发现 -t 的模版下面有四种模式,分别是app、module、package、plugin

image.png



            // Flutter项目,主体是Flutter,其中包含iOS、Android、web等项目。
[app]       (default) Generate a Flutter application.


            // 1.主要用于在原生iOS、Android项目中添加Flutter模块,用于原生与Flutter混合开发。  
            // 2.也可作为flutter项目的一个模块引入至flutter项目中,用于flutter分模块开发。
[module]    Generate a project to add a Flutter module to an existing Android or 
            iOS application.



            // Futter模块,纯Dart代码 , 不需要原生代码实现,没有Android iOS目录。
            // 在flutter的pubspec.yaml文件中引入使用。
[package]   Generate a shareable Flutter project containing modular Dart code.



            //Flutter插件:用于Flutter无法实现的功能,使用原生来实现出来,然后通过插件在
            // Flutter项目原生实现的功能。在flutter的pubspec.yaml文件中引入使用。
[plugin]    Generate a shareable Flutter project containing an API in Dart code with a
            platform-specific implementation through method channels for Android, iOS, 
            Linux, macOS, Windows, web, or any combination of these.


             //用 Dart 语言编写针对一个或多个特定平台的 API实现,基于dart:ffi
[plugin_ffi] Generate a shareable Flutter project containing an API in Dart code with a
            platform-specific implementation through dart:ffi for Android, iOS, Linux,
            macOS, Windows, or any combination of these.


            // 示例程序
[skeleton]  Generate a List View / Detail View Flutter application that follows community best
                             practices.