打包

下载证书,本地安装到钥匙链中

配置Xcode

打包命令

修改项目的版本号和构建次数

若要使pubspec.yaml文件中的version生效,需要修改Android、iOS项目的配置文件。

Android项目配置文件修改

确认android/app/build.gradle文件中使用了Flutter的versionCode和versionName

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

android {
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
applicationId "com.xiaopeng.scepter"
minSdkVersion 21
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
Read More

沉浸式处理

基本使用(全局生效)

Flutter侧设置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

// 黑色沉浸式状态栏颜色 黑色文字
SystemUiOverlayStyle dark = const SystemUiOverlayStyle(
// systemNavigationBarColor: Color(0xFF000000),
systemNavigationBarDividerColor: null, //设置导航栏和内容区域的分割线颜色
systemNavigationBarIconBrightness:null, //设置导航栏图标的颜色,可选值为Brightness.light或Brightness.dark。
/// 注意安卓要想实现沉浸式的状态栏 需要底部设置透明色
statusBarColor: Colors.transparent, // 状态栏颜色为透明
systemNavigationBarIconBrightness: Brightness.light,
statusBarIconBrightness: Brightness.dark, // 设置状态栏图标的颜色,可选值为Brightness.light或Brightness.dark。
statusBarBrightness: Brightness.light, // 设置状态栏文字的颜色,可选值为Brightness.light或Brightness.dark。
);

SystemChrome.setSystemUIOverlayStyle(dark);

原生侧设置

1
2
3
4
5
6
7
8
9
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(0);//原生侧设置透明
}
}

Read More

Path的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

/// rect 圆弧所在的矩形
/// startAngle 初始化弧度
/// sweepAngle 需要绘制的弧度大小
/// forceMoveTo 是否强制连线
void arcTo(Rect rect, double startAngle, double sweepAngle, bool forceMoveTo) {
}



class ArcWidget extends StatefulWidget {
const ArcWidget({super.key});

@override
State<ArcWidget> createState() => _ArcWidgetState();
}

class _ArcWidgetState extends State<ArcWidget> {
@override
Widget build(BuildContext context) {
return Container(
height: 50.h,
child: CustomPaint(
painter: ArcPainter(),
child: Container(),
),
);
}
}

class ArcPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;

final path = Path()
..moveTo(0, size.height + 1) // Start at the bottom-left corner
..lineTo(0, size.height - 10.h) // Move up by 100 pixels
..quadraticBezierTo(size.width / 2, size.height - 48.h, size.width, size.height - 10.h) // Draw a quadratic bezier curve
..lineTo(size.width, size.height + 1) // Draw a line to the bottom-right corner
..close(); // Close the path

canvas.drawPath(path, paint);
}

@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
}