当前位置: 首页 > news >正文

Flutter 项目结构的区别

  1. 如果需要调用原生代码,请创建一个plugin类型的项目开发。
  2. 如果需要调用C语言,请参考文档:Flutter项目中调用C语言
  3. plugin 其实是 package 的一种,全称是 plugin package,我们简称为 plugin,中文叫插件。

1. Application

Flutter Application 表示一个Flutter项目,主体是Flutter,当然它也可以接入Android Module 或者 iOS Framework,其内部包含 Android 和 iOS 项目。

其目录结构如下:

目录描述备注
androidAndroid原生代码目录。其实就是一个内嵌的Android工程
iosiOS原生代码目录。

其实就是一个内嵌的iOS工程

可以通过xcode 打开 Runner.xcworkspace 进行项目配置

lib这个是Flutter项目的核心目录,我们写的代码放在这个目录,我们也可以在这个目录创建子目录。
test测试代码目录。
pubspec.yaml这个是Flutter项目的依赖配置文件,类似于Android build.gradle文件,这里面包含了Flutter SDK 版本、依赖等。

2. Plugin

Flutter Plugin表示 Flutter 插件,包含 Android 和 iOS 项目,如果你要开发一个 Plugin 且此 Plugin 涉及到原生支持,比如蓝牙功能、网络功能等,这些功能纯 Flutter 是无法实现的。
其目录比 Flutter Application 多了一个 example,example用于当前 Plugin 的demo, Flutter Plugin 开发完成后可以发布到 pub 上。
其目录结构如下:

其pubspec.ymal中多了关于该插件的名称,描述,版本等信息

name: plugin_demo
description: A new Flutter project.
version: 0.0.1
homepage:

此外还多了此插件关于平台的配置

  # This section identifies this Flutter project as a plugin project.# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)# which should be registered in the plugin registry. This is required for# using method channels.# The Android 'package' specifies package in which the registered class is.# This is required for using method channels on Android.# The 'ffiPlugin' specifies that native code should be built and bundled.# This is required for using `dart:ffi`.# All these are used by the tooling to maintain consistency when# adding or updating assets for this project.plugin:platforms:android:package: com.example.plugin_demopluginClass: PluginDemoPluginios:pluginClass: PluginDemoPlugin

3. Package

Flutter Package 和 Flutter Plugin 基本一样,唯一的区别是Flutter Package表示纯 Flutter 模块,不需要原生开发,没有Android 和 iOS 项目,比如开发一个纯 UI 的插件。
其目录结构如下:

4. Module

Flutter Module 用于原生项目中插入 Flutter 模块,原生为主体,与 Flutter 进行混合开发。
其目录结构如下:

5. 参考指令

flutter create  指令用法说明

flutter create <output directory>-h, --help                   Print this usage information.--[no-]pub               Whether to run "flutter pub get" after the projecthas been created.(defaults to on)--[no-]offline           When "flutter pub get" is run by the createcommand, this indicates whether to run it inoffline mode or not. In offline mode, it will needto have all dependencies already available in thepub cache to succeed.--[no-]overwrite         When performing operations, overwrite existingfiles.--description            The description to use for your new Flutterproject. This string ends up in the pubspec.yamlfile.(defaults to "A new Flutter project.")--org                    The organization responsible for your new Flutterproject, in reverse domain name notation. Thisstring is used in Java package names and as prefixin the iOS bundle identifier.(defaults to "com.example")--project-name           The project name for this new Flutter project. Thismust be a valid dart package name.
-i, --ios-language           The language to use for iOS-specific code, eitherObjective-C (legacy) or Swift (recommended).[objc, swift (default)]
-a, --android-language       The language to use for Android-specific code,either Java (legacy) or Kotlin (recommended).[java, kotlin (default)]--platforms              The platforms supported by this project. Platformfolders (e.g. android/) will be generated in thetarget project. This argument only works when"--template" is set to app or plugin. When addingplatforms to a plugin project, the pubspec.yamlwill be updated with the requested platform. Addingdesktop platforms requires the correspondingdesktop config setting to be enabled.[ios (default), android (default), windows(default), linux (default), macos (default), web(default)]
-t, --template=<type>        Specify the type of project to create.[app]              (default) Generate a Flutter application.[module]           Generate a project to add a Flutter module to anexisting Android or iOS application.[package]          Generate a shareable Flutter project containingmodular Dart code.[plugin]           Generate a shareable Flutter project containing anAPI in Dart code with a platform-specificimplementation through method channels for Android,iOS, Linux, macOS, Windows, web, or any combinationof these.[plugin_ffi]       Generate a shareable Flutter project containing anAPI in Dart code with a platform-specificimplementation through dart:ffi for Android, iOS,Linux, macOS, Windows, or any combination of these.[skeleton]         Generate a List View / Detail View Flutterapplication that follows community best practices.-s, --sample=<id>            Specifies the Flutter code sample to use as the"main.dart" for an application. Implies"--template=app". The value should be the sample IDof the desired sample from the API documentationwebsite (https://api.flutter.dev/). An example canbe found at:https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html
-e, --[no-]empty             Specifies creating using an application templatewith a main.dart that is minimal, including nocomments, as a starting point for a newapplication. Implies "--template=app".--list-samples=<path>    Specifies a JSON output file for a listing ofFlutter code samples that can be created with"--sample".

例如创建一个插件

flutter create --template=package hello

相关文章:

Flutter 项目结构的区别

如果需要调用原生代码&#xff0c;请创建一个plugin类型的项目开发。如果需要调用C语言&#xff0c;请参考文档&#xff1a;Flutter项目中调用C语言plugin 其实是 package 的一种&#xff0c;全称是 plugin package&#xff0c;我们简称为 plugin&#xff0c;中文叫插件。 1. A…...

EfficientFormerV2:重新思考视觉变换器以实现与MobileNet相当的尺寸和速度。

摘要 https://arxiv.org/pdf/2212.08059 随着视觉变换器&#xff08;ViTs&#xff09;在计算机视觉任务中的成功&#xff0c;近期的研究尝试优化ViTs的性能和复杂度&#xff0c;以实现在移动设备上的高效部署。提出了多种方法来加速注意力机制&#xff0c;改进低效设计&#xf…...

ASP.NET Core高效管理字符串集合

我们在开发 Web 项目时经常遇到需要管理各种来源的字符串集合&#xff08;例如HTTP 标头、查询字符串、设置的值等&#xff09;的情况。合理的管理这些字符串集合不仅可以减少出bug的几率&#xff0c;也能提高应用程序的性能。ASP.NET Core 为我们提供了一种特殊的只读结构体 S…...

vm-tools的卸载重装,只能复制粘贴,无法拖拽文件!

开始 ubuntu22.04 LTSVMwareTools-10.3.25-20206839.tar.gzVMware Workstation 17 Pro 各种该尝试的配置都尝试了,比如: 1.开启复制粘贴拖拽; 2.VMware Tools拖拽失效; 3.解决VMware无法拖拽. 均没有奏效. 安装过程报错, 报错异常: The installation of VMware Tools 10.3.25…...

Docker 容器网络技术

Docker 容器网络技术 一、概述 Docker 容器技术在微服务架构和云原生应用中扮演着重要角色。容器的轻量化和快速启动特性&#xff0c;使得它们成为现代应用部署的首选。然而&#xff0c;容器的网络连接和管理是一个复杂的问题&#xff0c;尤其是当涉及到容器间通信时。Docker…...

C++ 起始帧数、结束帧数、剪辑视频

C 指定起始帧数、结束帧数、 剪辑视频 C 无法直接用H264&#xff0c;只能用avi编码格式 #include <iostream> #include <opencv2/opencv.hpp>int main() {// 读取视频&#xff1a;创建了一个VideoCapture对象&#xff0c;参数为摄像头编号std::string path &quo…...

【项目一】基于pytest的自动化测试框架———解读requests模块

解读python的requests模块 什么是requests模块基础用法GET与POST的区别数据传递格式会话管理与持久性连接处理相应结果应对HTTPS证书验证错误处理与异常捕获 这篇blog主要聚焦如何使用 Python 中的 requests 模块来实现接口自动化测试。下面我介绍一下 requests 的常用方法、数…...

升级Ubuntu内核的几种方法

注意&#xff1a; Ubuntu主线内核由 Ubuntu 内核团队提供&#xff0c;用于测试和调试目的。 它们不受支持且不适合生产使用。 仅当它们可以解决当前内核遇到的关键问题时&#xff0c;才应该安装它们。 1、手动下载deb文件升级内核 来源&#xff1a;kernel.ubuntu.com/main…...

Android绘制靶面,初步点击位置区域划分取值测试

自定义View&#xff1a; public class TargetView extends View {private Paint paint;private int[] radii {100, 250, 400, 550, 700}; // 五个圆的半径private int numberOfSegments 8;private int[][] regionValues; // 存储每个区域的值public TargetView(Context cont…...

【SpringBoot】调度和执行定时任务--Quartz(超详细)

Quartz 是一个功能强大的任务调度框架&#xff0c;广泛用于在 Java 应用程序中定时执行任务&#xff0c;同时它支持 Cron 表达式、持久化任务、集群等特性。以下是 Quartz 的详细使用教程&#xff0c;包括安装、基本概念、简单示例和高级功能。 1. 安装 Quartz 首先&#xff…...

低代码开发平台系统架构概述

概述 织信低代码开发平台&#xff08;产品全称&#xff1a;织信Informat&#xff09;是一款集成了应用设计、运行与管理的综合性平台。它提供了丰富的功能模块&#xff0c;帮助用户快速构建、部署和维护应用程序。织信低代码平台通过集成丰富的功能模块&#xff0c;为用户提供…...

源码编译llama.cpp 、ggml 后端启用自定义BLAS加速

源码编译llama.cpp 、ggml 后端启用自定义BLAS加速 我在llama.cpp 官网上提交了我的解决方案&#xff1a;How to setup OpenBlas on windows? #625 GGML 官网 https://github.com/ggerganov/ggml/issues/959 windows on arm 编译 llama.cpp 、ggml 后端启用自定义BLAS加速 …...

glb数据格式

glb数据格式 glb 文件格式只包含一个glb 文件&#xff0c;文件按照二进制存储&#xff0c;占空间小 浏览 浏览glb工具的很多&#xff0c;ccs&#xff0c;3D查看器等都可以&#xff0c;不安装软件的话用下面网页加载就可以&#xff0c;免费 glTF Viewer (donmccurdy.com) glb…...

手语识别系统源码分享

手语识别检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer Vision …...

Oracle 数据库部署与实施

文章目录 1. macOS 上部署 Oracle 数据库通过 Docker 在 macOS 上部署 2. Linux 上部署 Oracle 数据库直接在 Linux 上部署通过 Docker 在 Linux 上部署 3. Windows 上部署 Oracle 数据库4. 使用 Docker 部署 Oracle 数据库前提条件拉取 Oracle 数据库 Docker 镜像运行 Oracle …...

【Python】 ast.literal_eval 与 eval

一、背景 我在在编写管理后台的过程中&#xff0c;遇到一个小问题&#xff0c;是关于用户名的存储和解码。用户名以base64编码的形式存储在 MySQL 数据库中&#xff0c;并且还保留了b这样的形式&#xff0c;具体为什么要这样存我也不知道,可能是因为有些特殊字符无法直接存储。…...

Java 入门指南:JVM(Java虚拟机)垃圾回收机制 —— 新一代垃圾回收器 ZGC 收集器

文章目录 垃圾回收机制垃圾收集器垃圾收集器分类ZGC 收集器ZGC 的性能优势复制算法指针染色读屏障 ZGC 的工作过程Stop-The-World 暂停阶段并发阶段 垃圾回收机制 垃圾回收&#xff08;Garbage Collection&#xff0c;GC&#xff09;&#xff0c;顾名思义就是释放垃圾占用的空…...

基于 K8S kubernetes 的常见日志收集方案

目录 1、日志对我们来说到底重不重要&#xff1f; 2、常见的日志收集方案 2.1 EFK 2.2 ELK Stack 2.3 ELKfilebeat 2.4 其他方案 2、elasticsearch组件介绍 3、filebeat组件介绍 3.1 filebeat和beat关系 3.2 filebeat是什么&#xff1f; 3.3 Filebeat工作原理 3.4 …...

Unity3D 小案例 像素贪吃蛇 02 蛇的觅食

Unity3D 小案例 像素贪吃蛇 第二期 蛇的觅食 像素贪吃蛇 食物生成 在场景中创建一个 2D 正方形&#xff0c;调整颜色&#xff0c;添加 Tag 并修改为 Food。 然后拖拽到 Assets 文件夹中变成预制体。 创建食物管理器 FoodManager.cs&#xff0c;添加单例&#xff0c;可以设置…...

【sgCreateCallAPIFunction】自定义小工具:敏捷开发→调用接口方法代码生成工具

<template><div :class"$options.name" class"sgDevTool"><sgHead /><div class"sg-container"><div class"sg-start"><div style"margin-bottom: 10px">调用接口方法定义列表</div…...

铭豹扩展坞 USB转网口 突然无法识别解决方法

当 USB 转网口扩展坞在一台笔记本上无法识别,但在其他电脑上正常工作时,问题通常出在笔记本自身或其与扩展坞的兼容性上。以下是系统化的定位思路和排查步骤,帮助你快速找到故障原因: 背景: 一个M-pard(铭豹)扩展坞的网卡突然无法识别了,扩展出来的三个USB接口正常。…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

在鸿蒙HarmonyOS 5中实现抖音风格的点赞功能

下面我将详细介绍如何使用HarmonyOS SDK在HarmonyOS 5中实现类似抖音的点赞功能&#xff0c;包括动画效果、数据同步和交互优化。 1. 基础点赞功能实现 1.1 创建数据模型 // VideoModel.ets export class VideoModel {id: string "";title: string ""…...

Go 语言接口详解

Go 语言接口详解 核心概念 接口定义 在 Go 语言中&#xff0c;接口是一种抽象类型&#xff0c;它定义了一组方法的集合&#xff1a; // 定义接口 type Shape interface {Area() float64Perimeter() float64 } 接口实现 Go 接口的实现是隐式的&#xff1a; // 矩形结构体…...

dedecms 织梦自定义表单留言增加ajax验证码功能

增加ajax功能模块&#xff0c;用户不点击提交按钮&#xff0c;只要输入框失去焦点&#xff0c;就会提前提示验证码是否正确。 一&#xff0c;模板上增加验证码 <input name"vdcode"id"vdcode" placeholder"请输入验证码" type"text&quo…...

电脑插入多块移动硬盘后经常出现卡顿和蓝屏

当电脑在插入多块移动硬盘后频繁出现卡顿和蓝屏问题时&#xff0c;可能涉及硬件资源冲突、驱动兼容性、供电不足或系统设置等多方面原因。以下是逐步排查和解决方案&#xff1a; 1. 检查电源供电问题 问题原因&#xff1a;多块移动硬盘同时运行可能导致USB接口供电不足&#x…...

[ICLR 2022]How Much Can CLIP Benefit Vision-and-Language Tasks?

论文网址&#xff1a;pdf 英文是纯手打的&#xff01;论文原文的summarizing and paraphrasing。可能会出现难以避免的拼写错误和语法错误&#xff0c;若有发现欢迎评论指正&#xff01;文章偏向于笔记&#xff0c;谨慎食用 目录 1. 心得 2. 论文逐段精读 2.1. Abstract 2…...

如何将联系人从 iPhone 转移到 Android

从 iPhone 换到 Android 手机时&#xff0c;你可能需要保留重要的数据&#xff0c;例如通讯录。好在&#xff0c;将通讯录从 iPhone 转移到 Android 手机非常简单&#xff0c;你可以从本文中学习 6 种可靠的方法&#xff0c;确保随时保持连接&#xff0c;不错过任何信息。 第 1…...

【单片机期末】单片机系统设计

主要内容&#xff1a;系统状态机&#xff0c;系统时基&#xff0c;系统需求分析&#xff0c;系统构建&#xff0c;系统状态流图 一、题目要求 二、绘制系统状态流图 题目&#xff1a;根据上述描述绘制系统状态流图&#xff0c;注明状态转移条件及方向。 三、利用定时器产生时…...

Mac下Android Studio扫描根目录卡死问题记录

环境信息 操作系统: macOS 15.5 (Apple M2芯片)Android Studio版本: Meerkat Feature Drop | 2024.3.2 Patch 1 (Build #AI-243.26053.27.2432.13536105, 2025年5月22日构建) 问题现象 在项目开发过程中&#xff0c;提示一个依赖外部头文件的cpp源文件需要同步&#xff0c;点…...