feat: init project
This commit is contained in:
parent
d2b8ae5f65
commit
39187a59ee
@ -1,67 +1,100 @@
|
||||
// 应用插件
|
||||
plugins {
|
||||
// Android应用程序插件,用于构建Android应用
|
||||
id "com.android.application"
|
||||
// Kotlin Android插件,支持Kotlin语言开发
|
||||
id "kotlin-android"
|
||||
// Flutter Gradle插件,用于集成Flutter框架
|
||||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
// 定义局部属性变量
|
||||
def localProperties = new Properties()
|
||||
// 获取local.properties文件
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
// 如果local.properties文件存在,则加载其内容
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
// 从local.properties中获取Flutter版本代码,如果不存在则默认为'1'
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
}
|
||||
|
||||
// 从local.properties中获取Flutter版本名称,如果不存在则默认为'1.0'
|
||||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||
if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
// Android配置块
|
||||
android {
|
||||
// 应用程序的命名空间
|
||||
namespace "com.example.starwork_flutter"
|
||||
// 编译SDK版本,使用Flutter配置的版本
|
||||
compileSdk flutter.compileSdkVersion
|
||||
// NDK版本,使用Flutter配置的版本
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
// Java编译选项
|
||||
compileOptions {
|
||||
// 源代码兼容性设置为Java 1.8
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
// 目标兼容性设置为Java 1.8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
// Kotlin编译选项
|
||||
kotlinOptions {
|
||||
// JVM目标版本设置为1.8
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
|
||||
// 源代码集配置
|
||||
sourceSets {
|
||||
// 添加Kotlin源代码目录
|
||||
main.java.srcDirs += 'src/main/kotlin'
|
||||
}
|
||||
|
||||
// 默认配置
|
||||
defaultConfig {
|
||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||
// 应用程序ID,唯一标识符
|
||||
applicationId "com.example.starwork_flutter"
|
||||
// You can update the following values to match your application needs.
|
||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
|
||||
minSdkVersion flutter.minSdkVersion
|
||||
targetSdkVersion flutter.targetSdkVersion
|
||||
// 最小SDK版本,设置为25
|
||||
minSdkVersion 25
|
||||
// 目标SDK版本,设置为35
|
||||
targetSdkVersion 35
|
||||
// 版本代码,用于应用商店区分版本
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
// 版本名称,用户可见的版本号
|
||||
versionName flutterVersionName
|
||||
// 设置支持的ABI架构
|
||||
ndk {
|
||||
// abiFilters "arm64-v8a"
|
||||
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||||
}
|
||||
}
|
||||
|
||||
// 构建类型配置
|
||||
buildTypes {
|
||||
// 发布版本配置
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
// 签名配置,使用调试密钥
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Flutter配置块
|
||||
flutter {
|
||||
// Flutter源代码路径
|
||||
source '../..'
|
||||
}
|
||||
|
||||
// 依赖项配置
|
||||
// 目前没有添加任何依赖项
|
||||
dependencies {}
|
||||
|
||||
106
flavorizr.yaml
Normal file
106
flavorizr.yaml
Normal file
@ -0,0 +1,106 @@
|
||||
# 用于编译出不同的APPID
|
||||
|
||||
# 生成:意思是将本文件定义的配置,生成对应的代码,或者原生的配置、构建过程、文件资源等
|
||||
# 风味用法:dart run flutter_flavorizr -p <processor_1>,<processor_2>
|
||||
|
||||
# 以下行为都是覆盖,所以如果不是很清楚自己在做什么,请不要随意运行,以免覆盖有用的文件
|
||||
# 安卓图标:dart run flutter_flavorizr -p android:icons
|
||||
# 安卓构建参数集配置:dart run flutter_flavorizr -p android:androidManifest
|
||||
# 安卓构建目标配置:dart run flutter_flavorizr -p android:buildGradle
|
||||
# 用法-生成iOS图标:dart run flutter_flavorizr -p ios:icons
|
||||
|
||||
# Scheme 定义了构建目标、测试、运行、调试和分析应用程序的方式。它是Xcode中一个关键的组件,用于配置不同的构建设置和运行环境。
|
||||
# 可以有针对不同目的的多个Schemes,例如一个用于调试的Scheme、一个用于发布的Scheme,以及用于不同测试环境的Scheme。
|
||||
# 用法 :dart run flutter_flavorizr -p ios:schema
|
||||
|
||||
# XCConfig文件是Xcode配置文件,用于外部化和管理项目的构建设置。通过使用这些文件,可以更容易地管理和共享构建配置。
|
||||
# 可以为不同的构建环境(如Debug和Release)或不同的应用flavor配置多个XCConfig文件。
|
||||
# 用法:dart run flutter_flavorizr -p ios:xcconfig
|
||||
|
||||
# Build Target定义了一个构建过程,它描述了如何编译和链接构建应用程序的源代码。每个Target可以有不同的配置和目的(例如,一个应用程序Target、一个单元测试Target)。
|
||||
# 可能包括应用程序本身的Target、测试Target、用于不同flavor的Target,或者针对不同平台(如iOS和macOS)的Target。
|
||||
# 用法:dart run flutter_flavorizr -p ios:buildTargets
|
||||
|
||||
# Plist文件用于存储应用程序的配置信息,如应用版本号、显示名称等。它是一个XML文件,Xcode在构建应用程序时会读取它
|
||||
# 每个Target通常有自己的Info.plist文件,还可能有其他Plist文件来管理不同的配置和设置。
|
||||
# 用法:dart run flutter_flavorizr -p ios:plist
|
||||
|
||||
# LaunchScreen(启动屏幕)是应用启动时显示的界面,通常包含应用的Logo和名称。它在应用加载期间显示,提供更好的用户体验。
|
||||
# 可以针对不同的设备和屏幕尺寸配置多个LaunchScreen,或者为不同的版本或flavor提供不同的启动屏幕。
|
||||
# 用法:dart run flutter_flavorizr -p ios:launchScreen
|
||||
|
||||
|
||||
# 项目运行说明:添加不同风味后,不能再使用flutter默认的运行方式`flutter run`,而是需要指定运行的风味
|
||||
# flutter run --flavor <flavor> -t lib/main_<flavor>.dart
|
||||
# 注意,这里有 入口文件(main_<flavor>.dart) 和 口味(<flavor>) 两个参数
|
||||
# 其中入口文件在代码中指定运行时的差异,例如 页面上的名称、颜色、API请求的域名等
|
||||
# 而 口味 指定 构建差异,例如 APPID、Logo、应用名称等
|
||||
# 下面是4个运行示例:
|
||||
# flutter run --flavor dev -t lib/main_dev.dart
|
||||
# flutter run --flavor pre -t lib/main_pre.dart
|
||||
# flutter run --flavor sky -t lib/main_sky_full.dart
|
||||
# flutter run --flavor xhj -t lib/main_xhj_full.dart
|
||||
|
||||
# 下面是安卓发布编译命令
|
||||
# flutter build apk --split-per-abi --release --flavor sky -t lib/main_sky_full.dart
|
||||
# flutter build apk --release --flavor sky -t lib/main_sky_full.dart
|
||||
|
||||
# IOS编译发布
|
||||
# TODO 待补充
|
||||
|
||||
app:
|
||||
android:
|
||||
flavorDimensions: "flavor-type"
|
||||
|
||||
flavors:
|
||||
local:
|
||||
app:
|
||||
name: "星锁-local"
|
||||
icon: "assets/icon/dev.png"
|
||||
android:
|
||||
applicationId: "com.starlock.lock.local"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.pre
|
||||
ios:
|
||||
bundleId: "com.starlock.lock.local"
|
||||
dev:
|
||||
app:
|
||||
name: "星锁-dev"
|
||||
icon: "assets/icon/dev.png"
|
||||
android:
|
||||
applicationId: "com.starlock.lock.dev"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.pre
|
||||
ios:
|
||||
bundleId: "com.starlock.lock.dev"
|
||||
pre:
|
||||
app:
|
||||
name: "星锁"
|
||||
icon: "assets/icon/pre.png"
|
||||
android:
|
||||
applicationId: "com.starlock.lock.pre"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.pre
|
||||
ios:
|
||||
bundleId: "com.starlock.lock.pre"
|
||||
sky:
|
||||
app:
|
||||
name: "锁通通"
|
||||
icon: "assets/icon/sky.png"
|
||||
android:
|
||||
applicationId: "com.skychip.lock"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.sky
|
||||
ios:
|
||||
bundleId: "com.skychip.lock"
|
||||
xhj:
|
||||
app:
|
||||
name: "星星锁"
|
||||
icon: "assets/icon/xhj.png"
|
||||
android:
|
||||
applicationId: "com.xhjcn.lock"
|
||||
customConfig:
|
||||
signingConfig: signingConfigs.xhj
|
||||
ios:
|
||||
bundleId: "com.xhjcn.lock"
|
||||
ide: idea
|
||||
12
lib/base/app_flavor.dart
Normal file
12
lib/base/app_flavor.dart
Normal file
@ -0,0 +1,12 @@
|
||||
class AppFlavor {
|
||||
static const String sky = 'sky';
|
||||
static const String xhj = 'xhj';
|
||||
static const String current = String.fromEnvironment(
|
||||
'FLAVOR',
|
||||
defaultValue: sky,
|
||||
);
|
||||
|
||||
static bool get isSky => current == sky;
|
||||
|
||||
static bool get isXhj => current == xhj;
|
||||
}
|
||||
112
pubspec.lock
112
pubspec.lock
@ -1,6 +1,22 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.0.7"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -25,6 +41,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: checked_yaml
|
||||
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -41,6 +65,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -78,6 +110,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_flavorizr:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_flavorizr
|
||||
sha256: "5aa088f6c2a7b7f96dc86818fe1bb2d32f4e33ecf0745053c832742221d0c7be"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@ -112,6 +152,30 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.7.2"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
sha256: "4e973fcf4caae1a4be2fa0a13157aa38a8f9cb049db6529aa00b4d71abc4d928"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.5.4"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "4.9.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -248,6 +312,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.0.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -264,6 +336,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
posix:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: posix
|
||||
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -333,6 +413,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
sprintf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sprintf
|
||||
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -373,6 +461,14 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.6.1"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -405,6 +501,22 @@ packages:
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "6.5.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
sdks:
|
||||
dart: ">=3.3.4 <4.0.0"
|
||||
flutter: ">=3.19.0"
|
||||
|
||||
@ -23,10 +23,13 @@ dependencies:
|
||||
# 屏幕适配
|
||||
flutter_screenutil: ^5.9.3
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^3.0.0
|
||||
# 多flavor
|
||||
flutter_flavorizr: ^2.3.1
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user