临时
This commit is contained in:
21
lib/common.dart
Normal file
21
lib/common.dart
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user