Browse Source

fix : 移除警告

dev
徐振升 2 weeks ago
parent
commit
32c29fa045
  1. 1
      .vscode/settings.json
  2. 30
      build_flutter_app.dart
  3. 34
      lib/app/core/services/sync_service.dart
  4. 16
      lib/app/core/services/upgrader_service.dart
  5. 2
      lib/app/features/enterprise/presentation/controllers/enterprise_upload_controller.dart
  6. 38
      lib/app/features/enterprise/presentation/pages/enterprise_form_page.dart
  7. 4
      lib/app/features/enterprise/presentation/pages/enterprise_upload_page.dart
  8. 1
      lib/app/features/navigation/presentation/controllers/navigation_controller.dart
  9. 34
      lib/app/features/problem/presentation/views/problem_upload_page.dart

1
.vscode/settings.json vendored

@ -2,6 +2,7 @@
"cSpell.words": [
"fenix",
"Getx",
"Syncable",
"tdesign",
"usecase",
"usecases"

30
build_flutter_app.dart

@ -1,8 +1,10 @@
import 'dart:io';
import 'dart:convert';
import 'package:flutter/foundation.dart';
void main(List<String> arguments) async {
print('🚀 开始构建Flutter Android应用...');
debugPrint('🚀 开始构建Flutter Android应用...');
// ARM64 + ARM32
final targetPlatform = arguments.contains('--arm64-only')
@ -19,28 +21,28 @@ void main(List<String> arguments) async {
// version.json文件
await generateVersionJson(apkPath, targetPlatform);
print('✅ 构建完成!');
print('📦 APK位置: $apkPath');
debugPrint('✅ 构建完成!');
debugPrint('📦 APK位置: $apkPath');
} catch (e) {
print('❌ 构建过程中出现错误: $e');
debugPrint('❌ 构建过程中出现错误: $e');
exit(1);
}
}
Future<String> buildFlutterApp(String targetPlatform) async {
print('📱 正在构建Flutter Android应用...');
print('🎯 目标平台: $targetPlatform');
debugPrint('📱 正在构建Flutter Android应用...');
debugPrint('🎯 目标平台: $targetPlatform');
//
print('🧹 清理构建缓存...');
debugPrint('🧹 清理构建缓存...');
await runFlutterCommand(['clean']);
// pub依赖
print('📦 获取依赖...');
debugPrint('📦 获取依赖...');
await runFlutterCommand(['pub', 'get']);
// APK
print('🔨 构建Release APK...');
debugPrint('🔨 构建Release APK...');
await runFlutterCommand([
'build',
'apk',
@ -48,7 +50,7 @@ Future<String> buildFlutterApp(String targetPlatform) async {
'--target-platform=$targetPlatform',
]);
print('✅ Flutter应用构建成功!');
debugPrint('✅ Flutter应用构建成功!');
// APK文件名
String apkName;
@ -71,7 +73,7 @@ Future<void> runFlutterCommand(List<String> args) async {
}
Future<void> generateVersionJson(String apkPath, String targetPlatform) async {
print('📄 正在生成version.json文件...');
debugPrint('📄 正在生成version.json文件...');
final apkFile = File(apkPath);
String fileSize = '未知';
@ -79,7 +81,7 @@ Future<void> generateVersionJson(String apkPath, String targetPlatform) async {
if (await apkFile.exists()) {
final apkSize = await apkFile.length();
fileSize = '${(apkSize / (1024 * 1024)).toStringAsFixed(1)}MB';
print('📦 APK文件大小: $fileSize');
debugPrint('📦 APK文件大小: $fileSize');
}
final now = DateTime.now();
@ -102,7 +104,7 @@ Future<void> generateVersionJson(String apkPath, String targetPlatform) async {
const JsonEncoder.withIndent(' ').convert(versionInfo),
);
print('✅ version.json文件生成成功!');
debugPrint('✅ version.json文件生成成功!');
}
String getBuildNumber() {
@ -115,5 +117,5 @@ Future<void> checkFlutterEnvironment() async {
if (result.exitCode != 0) {
throw Exception('Flutter环境检查失败');
}
print('✅ Flutter环境正常');
debugPrint('✅ Flutter环境正常');
}

34
lib/app/core/services/sync_service.dart

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:problem_check_system/app/core/models/sync_status.dart';
import 'package:problem_check_system/app/core/repositories/syncable_repository.dart';
@ -35,7 +36,7 @@ class SyncService extends GetxService {
void registerRepository<T extends SyncableEntity>(
SyncableRepository<T> repository,
) {
print('[SyncService] Registering repository for type: $T');
debugPrint('[SyncService] Registering repository for type: $T');
_repositories[T] = repository;
}
@ -46,7 +47,7 @@ class SyncService extends GetxService {
/// 1. ****:
/// 2. ****:
Future<void> performFullSync() async {
print('[SyncService] === Starting Full Sync Cycle ===');
debugPrint('[SyncService] === Starting Full Sync Cycle ===');
// :
await _pushAllPendingChanges();
@ -54,7 +55,7 @@ class SyncService extends GetxService {
// :
await _pullAllServerUpdates();
print('[SyncService] === Full Sync Cycle Finished ===');
debugPrint('[SyncService] === Full Sync Cycle Finished ===');
}
/// --- --- ///
@ -62,18 +63,18 @@ class SyncService extends GetxService {
/// ****
///
Future<void> _pushAllPendingChanges() async {
print('[SyncService] >> Phase 1: Pushing local changes...');
debugPrint('[SyncService] >> Phase 1: Pushing local changes...');
// : feature
// `_getAllPendingItems()`
final List<SyncableEntity> allPendingItems = await _getAllPendingItems();
if (allPendingItems.isEmpty) {
print('[SyncService] No local changes to push.');
debugPrint('[SyncService] No local changes to push.');
return;
}
print(
debugPrint(
'[SyncService] Found ${allPendingItems.length} pending items to push.',
);
@ -81,19 +82,19 @@ class SyncService extends GetxService {
try {
await _syncSingleItem(item);
} catch (e) {
print(
debugPrint(
'[SyncService] ERROR: Failed to push item ${item.id} of type ${item.runtimeType}. Error: $e',
);
// :
}
}
print('[SyncService] << Push phase completed.');
debugPrint('[SyncService] << Push phase completed.');
}
/// ****
///
Future<void> _pullAllServerUpdates() async {
print('[SyncService] >> Phase 2: Pulling server updates...');
debugPrint('[SyncService] >> Phase 2: Pulling server updates...');
//
final DateTime syncCycleStartTime = DateTime.now().toUtc();
@ -108,7 +109,7 @@ class SyncService extends GetxService {
entityType,
);
print(
debugPrint(
'[SyncService] Pulling updates for $entityType since: ${lastSyncTimestamp ?? 'the beginning'}',
);
@ -120,17 +121,17 @@ class SyncService extends GetxService {
entityType,
syncCycleStartTime,
);
print(
debugPrint(
'[SyncService] Successfully pulled and updated timestamp for $entityType.',
);
} catch (e) {
print(
debugPrint(
'[SyncService] ERROR: Failed to pull updates for $entityType. Error: $e',
);
// :
}
}
print('[SyncService] << Pull phase completed.');
debugPrint('[SyncService] << Pull phase completed.');
}
///
@ -138,13 +139,13 @@ class SyncService extends GetxService {
final repository = _repositories[item.runtimeType];
if (repository == null) {
print(
debugPrint(
'[SyncService] WARNING: No repository registered for type ${item.runtimeType}. Skipping item ${item.id}.',
);
return;
}
print(
debugPrint(
'[SyncService] Pushing item ${item.id} (${item.runtimeType}) with status ${item.syncStatus.name}...',
);
@ -162,7 +163,6 @@ class SyncService extends GetxService {
//
break;
case SyncStatus.untracked:
// TODO: Handle this case.
throw UnimplementedError();
}
}
@ -178,7 +178,7 @@ class SyncService extends GetxService {
// final enterprises = await enterpriseLocalDataSource.getPendingEnterprises();
// return [...problems, ...enterprises];
print(
debugPrint(
'[SyncService] WARNING: _getAllPendingItems() is not implemented. Returning empty list.',
);
return []; //

16
lib/app/core/services/upgrader_service.dart

@ -77,23 +77,23 @@ class UpgraderService extends GetxService {
if (dir == null) {
Get.back(); //
Get.snackbar('错误', '无法获取外部存储目录。');
print('错误: getExternalStorageDirectory() 返回 null');
Get.log('错误: getExternalStorageDirectory() 返回 null');
isDownloading.value = false;
return; // 退
}
String savePath = '${dir.path}/app-release.apk';
print('--- 调试信息 ---');
print('目标下载路径: $savePath');
print('--- 调试信息 ---');
Get.log('--- 调试信息 ---');
Get.log('目标下载路径: $savePath');
Get.log('--- 调试信息 ---');
//
final file = File(savePath);
if (!await file.parent.exists()) {
await file.parent.create(recursive: true);
print('--- 调试信息 ---');
print('已尝试创建父目录: ${file.parent.path}');
print('--- 调试信息 ---');
Get.log('--- 调试信息 ---');
Get.log('已尝试创建父目录: ${file.parent.path}');
Get.log('--- 调试信息 ---');
}
await _dio.download(
@ -205,7 +205,7 @@ class UpgraderService extends GetxService {
//
Future<void> _openApkFile(String path) async {
final result = await OpenFile.open(path);
print('OpenFile result: ${result.type}, message: ${result.message}');
Get.log('OpenFile result: ${result.type}, message: ${result.message}');
if (result.type != ResultType.done) {
Get.snackbar('安装失败', '无法启动安装程序: ${result.message}');
}

2
lib/app/features/enterprise/presentation/controllers/enterprise_upload_controller.dart

@ -69,7 +69,7 @@ class EnterpriseUploadController extends GetxController {
return;
}
// ...
print('正在上传 ${selectedEnterprises.length} 个企业...');
Get.log('正在上传 ${selectedEnterprises.length} 个企业...');
// true
Get.back(result: true);

38
lib/app/features/enterprise/presentation/pages/enterprise_form_page.dart

@ -29,44 +29,6 @@ class EnterpriseFormPage extends GetView<EnterpriseFormController> {
);
}
// controller
PreferredSizeWidget _buildAppBar() {
return AppBar(
// ... AppBar
// 使 Obx pageTitle
title: Obx(
() => Text(
controller.pageTitle.value,
style: TextStyle(
fontSize: 18.sp,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
leading: IconButton(
icon: Icon(
Icons.arrow_back_ios_new_rounded,
size: 24.sp,
color: Colors.white,
),
onPressed: () => Get.back(),
),
backgroundColor: Colors.transparent,
flexibleSpace: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF418CFC), Color(0xFF3DBFFC)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
),
elevation: 0,
centerTitle: true,
);
}
//
Widget _buildBottomButtons() {
return Container(

4
lib/app/features/enterprise/presentation/pages/enterprise_upload_page.dart

@ -16,9 +16,7 @@ class EnterpriseUploadPage extends GetView<EnterpriseUploadController> {
selectedCount: 10,
selectedAll: true,
buttonVisible: false,
onButtonPressed: () {
print("object");
},
onButtonPressed: () {},
),
body: _buildEnterpriseList(),
bottomSheet: Container(

1
lib/app/features/navigation/presentation/controllers/navigation_controller.dart

@ -1,4 +1,3 @@
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

34
lib/app/features/problem/presentation/views/problem_upload_page.dart

@ -23,40 +23,6 @@ class ProblemUploadPage extends GetView<ProblemController> {
);
}
PreferredSizeWidget _buildAppBar() {
return AppBar(
title: Obx(() {
final selectedCount = controller.selectedCount;
return Text('已选择$selectedCount项');
}),
centerTitle: true,
// leading: IconButton(
// icon: Icon(Icons.close),
// onPressed: () {
// Get.back();
// controller.loadProblems();
// },
// ),
actions: [
Obx(
() => TextButton(
onPressed: controller.unUploadedProblems.isNotEmpty
? controller.selectAll
: null,
child: Text(
controller.allSelected.value ? '取消全选' : '全选',
style: TextStyle(
color: controller.unUploadedProblems.isNotEmpty
? Colors.blue
: Colors.grey,
),
),
),
),
],
);
}
Widget _buildBody() {
return Obx(() {
if (controller.unUploadedProblems.isEmpty) {

Loading…
Cancel
Save