1. 升级依赖版本
2. 解决运行项目警告日志问题 3. 优化代码
This commit is contained in:
@@ -5,7 +5,7 @@ import 'package:recording_tool/app/app.dart';
|
||||
import 'package:recording_tool/app/config/app_config.dart';
|
||||
import 'package:recording_tool/core/cache/app_storage.dart';
|
||||
import 'package:recording_tool/core/logging/app_logger.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:recording_tool/core/platform/app_platform_info.dart';
|
||||
|
||||
class AppBootstrapper {
|
||||
AppBootstrapper._();
|
||||
@@ -18,7 +18,7 @@ class AppBootstrapper {
|
||||
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
|
||||
await AppStorage.init();
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
final packageInfo = await AppPlatformInfo.packageInfo();
|
||||
|
||||
AppConfig.configure(environment: environment, packageInfo: packageInfo);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:recording_tool/core/platform/app_platform_info.dart';
|
||||
|
||||
enum AppEnvironment { dev, staging, prod }
|
||||
|
||||
@@ -18,13 +18,13 @@ class AppConfig {
|
||||
AppConfig._();
|
||||
|
||||
static late EnvironmentValues current;
|
||||
static PackageInfo? packageInfo;
|
||||
static AppPackageInfo? packageInfo;
|
||||
|
||||
static const appName = '飞行极控';
|
||||
|
||||
static void configure({
|
||||
required AppEnvironment environment,
|
||||
PackageInfo? packageInfo,
|
||||
AppPackageInfo? packageInfo,
|
||||
}) {
|
||||
AppConfig.packageInfo = packageInfo;
|
||||
current = switch (environment) {
|
||||
|
||||
@@ -94,8 +94,8 @@ class AppNavigator {
|
||||
barrierDismissible: dismissible,
|
||||
transitionDuration: duration,
|
||||
reverseTransitionDuration: duration,
|
||||
pageBuilder: (_, __, ___) => page,
|
||||
transitionsBuilder: (_, animation, __, child) {
|
||||
pageBuilder: (_, _, _) => page,
|
||||
transitionsBuilder: (_, animation, _, child) {
|
||||
return FadeTransition(opacity: animation, child: child);
|
||||
},
|
||||
),
|
||||
|
||||
78
lib/core/platform/app_platform_info.dart
Normal file
78
lib/core/platform/app_platform_info.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class AppPackageInfo {
|
||||
const AppPackageInfo({
|
||||
required this.appName,
|
||||
required this.packageName,
|
||||
required this.version,
|
||||
required this.buildNumber,
|
||||
});
|
||||
|
||||
factory AppPackageInfo.fromMap(Map<Object?, Object?> map) {
|
||||
return AppPackageInfo(
|
||||
appName: map['appName'] as String? ?? '',
|
||||
packageName: map['packageName'] as String? ?? '',
|
||||
version: map['version'] as String? ?? '',
|
||||
buildNumber: map['buildNumber'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
final String appName;
|
||||
final String packageName;
|
||||
final String version;
|
||||
final String buildNumber;
|
||||
}
|
||||
|
||||
class AppDeviceInfo {
|
||||
const AppDeviceInfo({
|
||||
required this.platform,
|
||||
required this.isPhysicalDevice,
|
||||
required this.values,
|
||||
});
|
||||
|
||||
factory AppDeviceInfo.fromMap(Map<Object?, Object?> map) {
|
||||
final values = <String, String>{};
|
||||
for (final entry in map.entries) {
|
||||
final key = entry.key;
|
||||
final value = entry.value;
|
||||
if (key is String && value != null) {
|
||||
values[key] = value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
final isPhysicalDevice = map['isPhysicalDevice'];
|
||||
return AppDeviceInfo(
|
||||
platform: map['platform'] as String? ?? Platform.operatingSystem,
|
||||
isPhysicalDevice: isPhysicalDevice is bool ? isPhysicalDevice : true,
|
||||
values: values,
|
||||
);
|
||||
}
|
||||
|
||||
final String platform;
|
||||
final bool isPhysicalDevice;
|
||||
final Map<String, String> values;
|
||||
}
|
||||
|
||||
class AppPlatformInfo {
|
||||
AppPlatformInfo._();
|
||||
|
||||
static const MethodChannel _channel = MethodChannel(
|
||||
'com.gdfw.fxjk/platform_info',
|
||||
);
|
||||
|
||||
static Future<AppPackageInfo> packageInfo() async {
|
||||
final result = await _channel.invokeMapMethod<Object?, Object?>(
|
||||
'packageInfo',
|
||||
);
|
||||
return AppPackageInfo.fromMap(result ?? const <Object?, Object?>{});
|
||||
}
|
||||
|
||||
static Future<AppDeviceInfo> deviceInfo() async {
|
||||
final result = await _channel.invokeMapMethod<Object?, Object?>(
|
||||
'deviceInfo',
|
||||
);
|
||||
return AppDeviceInfo.fromMap(result ?? const <Object?, Object?>{});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:recording_tool/core/platform/app_platform_info.dart';
|
||||
|
||||
class DeviceUtils {
|
||||
DeviceUtils._();
|
||||
@@ -19,36 +19,13 @@ class DeviceUtils {
|
||||
MediaQuery.paddingOf(context).bottom;
|
||||
|
||||
static Future<bool> isPhysicalDevice() async {
|
||||
final plugin = DeviceInfoPlugin();
|
||||
if (Platform.isAndroid) {
|
||||
return (await plugin.androidInfo).isPhysicalDevice;
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
return (await plugin.iosInfo).isPhysicalDevice;
|
||||
}
|
||||
return true;
|
||||
return (await AppPlatformInfo.deviceInfo()).isPhysicalDevice;
|
||||
}
|
||||
|
||||
static Future<Map<String, String>> deviceInfo() async {
|
||||
final plugin = DeviceInfoPlugin();
|
||||
if (Platform.isAndroid) {
|
||||
final info = await plugin.androidInfo;
|
||||
return {
|
||||
'platform': 'android',
|
||||
'brand': info.brand,
|
||||
'model': info.model,
|
||||
'systemVersion': info.version.release,
|
||||
};
|
||||
if (!Platform.isAndroid && !Platform.isIOS) {
|
||||
return {'platform': Platform.operatingSystem};
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
final info = await plugin.iosInfo;
|
||||
return {
|
||||
'platform': 'ios',
|
||||
'brand': info.systemName,
|
||||
'model': info.utsname.machine,
|
||||
'systemVersion': info.systemVersion,
|
||||
};
|
||||
}
|
||||
return {'platform': Platform.operatingSystem};
|
||||
return (await AppPlatformInfo.deviceInfo()).values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,17 @@ class RecordingPlatform {
|
||||
bool enableDoNotDisturb = true,
|
||||
String? displayName,
|
||||
}) async {
|
||||
final args = <String, dynamic>{
|
||||
'withAudio': withAudio,
|
||||
'enableDoNotDisturb': enableDoNotDisturb,
|
||||
};
|
||||
if (displayName != null) {
|
||||
args['displayName'] = displayName;
|
||||
}
|
||||
|
||||
final result = await _channel.invokeMapMethod<String, dynamic>(
|
||||
'startRecording',
|
||||
<String, dynamic>{
|
||||
'withAudio': withAudio,
|
||||
'enableDoNotDisturb': enableDoNotDisturb,
|
||||
if (displayName != null) 'displayName': displayName,
|
||||
},
|
||||
args,
|
||||
);
|
||||
return RecordingStartResult(
|
||||
outputPath: result?['outputPath'] as String?,
|
||||
|
||||
@@ -24,7 +24,7 @@ class AppNetworkImage extends StatelessWidget {
|
||||
width: width,
|
||||
height: height,
|
||||
fit: fit,
|
||||
placeholder: (_, __) => ColoredBox(
|
||||
placeholder: (_, _) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: const Center(
|
||||
child: SizedBox.square(
|
||||
@@ -33,7 +33,7 @@ class AppNetworkImage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
errorWidget: (_, __, ___) => ColoredBox(
|
||||
errorWidget: (_, _, _) => ColoredBox(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: Icon(
|
||||
Icons.image_not_supported_outlined,
|
||||
|
||||
@@ -61,7 +61,7 @@ class _AppRefreshListState<T> extends State<AppRefreshList<T>> {
|
||||
: ListView.separated(
|
||||
padding: widget.padding,
|
||||
itemCount: widget.items.length,
|
||||
separatorBuilder: (_, __) =>
|
||||
separatorBuilder: (_, _) =>
|
||||
widget.separator ?? const SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
return widget.itemBuilder(context, widget.items[index], index);
|
||||
|
||||
Reference in New Issue
Block a user