This commit is contained in:
mmc
2026-03-02 10:19:23 +08:00
parent 41756e1f51
commit b0cf903e8c
4 changed files with 49 additions and 26 deletions

21
lib/common.dart Normal file
View File

@@ -0,0 +1,21 @@
// 工具方法
import 'dart:convert';
import 'package:flutter/material.dart';
void printFullString(String text, {int chunkSize = 800}) {
if (text.isEmpty) return;
for (int i = 0; i < text.length; i += chunkSize) {
int end = (i + chunkSize < text.length) ? i + chunkSize : text.length;
debugPrint('[$i-$end/${text.length}]: ${text.substring(i, end)}');
}
}
String formatJson(String jsonStr) {
try {
final jsonObj = jsonDecode(jsonStr);
return const JsonEncoder.withIndent(' ').convert(jsonObj);
} catch (e) {
return jsonStr;
}
}