Reformat the whole codebase with 100 line width (#3403)

This commit is contained in:
Omar Hatem
2026-07-15 01:20:33 +03:00
committed by GitHub
parent 1241b28bec
commit 16ddc0837a
801 changed files with 17517 additions and 17091 deletions
+20 -25
View File
@@ -100,7 +100,8 @@ class JsonExplorerPage extends StatelessWidget {
final appDir = await getAppDir();
final filePath = appDir.path + '/.json_dump_temp.json';
await File(filePath).writeAsString(jsonString);
await ShareUtil.shareFile(filePath: filePath, fileName: path.basename(filePath), context: context);
await ShareUtil.shareFile(
filePath: filePath, fileName: path.basename(filePath), context: context);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Failed to share file: $e')),
@@ -143,11 +144,11 @@ class _JsonExplorerState extends State<JsonExplorer> {
void _buildItemList() {
_allItems.clear();
if (widget.data is Map) {
final map = widget.data as Map<String, dynamic>;
final sortedKeys = map.keys.toList()..sort();
for (final key in sortedKeys) {
_allItems.add(CacheItem(
key: key,
@@ -165,7 +166,7 @@ class _JsonExplorerState extends State<JsonExplorer> {
));
}
}
_applyFilter();
}
@@ -175,7 +176,7 @@ class _JsonExplorerState extends State<JsonExplorer> {
} else {
_filteredItems = _allItems.where((item) {
return item.displayKey.toLowerCase().contains(_searchQuery.toLowerCase()) ||
_valueContainsSearch(item.value, _searchQuery.toLowerCase());
_valueContainsSearch(item.value, _searchQuery.toLowerCase());
}).toList();
}
}
@@ -210,10 +211,10 @@ class _JsonExplorerState extends State<JsonExplorer> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final totalItems = widget.data is Map
? (widget.data as Map).length
: widget.data is List
? (widget.data as List).length
final totalItems = widget.data is Map
? (widget.data as Map).length
: widget.data is List
? (widget.data as List).length
: 0;
return Column(
@@ -230,9 +231,7 @@ class _JsonExplorerState extends State<JsonExplorer> {
prefixIcon: const Icon(Icons.search),
border: const OutlineInputBorder(),
isDense: true,
suffixText: _searchQuery.isNotEmpty
? '${_filteredItems.length} found'
: null,
suffixText: _searchQuery.isNotEmpty ? '${_filteredItems.length} found' : null,
),
onChanged: (value) {
setState(() {
@@ -245,7 +244,6 @@ class _JsonExplorerState extends State<JsonExplorer> {
],
),
),
Expanded(
child: _filteredItems.isEmpty && _searchQuery.isNotEmpty
? Center(
@@ -311,11 +309,11 @@ class CacheItemTile extends StatelessWidget {
Color _getTypeColor(BuildContext context, dynamic value) {
final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark;
if (value == null) {
return Colors.grey;
}
switch (value.runtimeType) {
case String:
return Colors.green;
@@ -337,22 +335,22 @@ class CacheItemTile extends StatelessWidget {
String _getValuePreview(dynamic value) {
if (value == null) return 'null';
if (value is Map) {
return '{${value.length} items}';
}
if (value is List) {
return '[${value.length} items]';
}
if (value is String) {
if (value.length > 100) {
return '"${value.substring(0, 97)}..."';
}
return '"$value"';
}
final str = value.toString();
if (str.length > 100) {
return '${str.substring(0, 97)}...';
@@ -407,9 +405,7 @@ class CacheItemTile extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: ListTile(
leading: Icon(
canNavigate
? (item.value is Map ? Icons.folder : Icons.list)
: Icons.description,
canNavigate ? (item.value is Map ? Icons.folder : Icons.list) : Icons.description,
color: _getTypeColor(context, item.value),
),
title: _buildHighlightedText(
@@ -433,8 +429,7 @@ class CacheItemTile extends StatelessWidget {
icon: const Icon(Icons.copy, size: 18),
tooltip: 'Copy ${item.displayKey}',
),
if (canNavigate)
const Icon(Icons.chevron_right),
if (canNavigate) const Icon(Icons.chevron_right),
],
),
onTap: canNavigate ? onTap : null,
@@ -442,4 +437,4 @@ class CacheItemTile extends StatelessWidget {
),
);
}
}
}
+8 -17
View File
@@ -24,8 +24,6 @@ class DevMoneroCallProfilerPage extends BasePage {
}
}
class PerformanceDebug extends StatefulWidget {
const PerformanceDebug({super.key});
@@ -68,7 +66,7 @@ class _PerformanceDebugState extends State<PerformanceDebug> {
return debugCallLength["MONERO_Wallet_init"]!.last;
}
late final String perfInfo = """
late final String perfInfo = """
---- Performance tuning
This page lists all calls that take place during the app runtime.-
As per Flutter docs we can read:
@@ -93,8 +91,8 @@ min: fastest execution (% of frame)
max: slowest execution (% of frame)
95th: 95% of the time, the function is faster than this amount of time (% of frame)
"""
.split("-\n")
.join(" ");
.split("-\n")
.join(" ");
late final frameTime = 8333;
late final frameGreenTier = frameTime ~/ 100;
@@ -113,7 +111,6 @@ max: slowest execution (% of frame)
return Colors.red;
}
@override
void initState() {
super.initState();
@@ -144,9 +141,7 @@ max: slowest execution (% of frame)
],
));
final keys = debugCallLength.keys.toList();
keys.sort((s1, s2) =>
_n95th(debugCallLength[s2]!) -
_n95th(debugCallLength[s1]!));
keys.sort((s1, s2) => _n95th(debugCallLength[s2]!) - _n95th(debugCallLength[s1]!));
for (var key in keys) {
final value = debugCallLength[key];
if (value == null) continue;
@@ -172,14 +167,10 @@ max: slowest execution (% of frame)
const Spacer(),
cw("${_str(total / 1000)}ms", perfc(total)),
]),
cw("average: ${_str(avg)}µs (~${_str(avg / (frameTime))}f)",
perfc(avg)),
cw("min: $minµs (~${_str(min / (frameTime) * 100)})",
perfc(min)),
cw("max: $maxµs (~${_str(max / (frameTime) * 100)}%)",
perfc(max)),
cw("95th: $npµs (~${_str(np / (frameTime) * 100)}%)",
perfc(np)),
cw("average: ${_str(avg)}µs (~${_str(avg / (frameTime))}f)", perfc(avg)),
cw("min: $minµs (~${_str(min / (frameTime) * 100)})", perfc(min)),
cw("max: $maxµs (~${_str(max / (frameTime) * 100)}%)", perfc(max)),
cw("95th: $npµs (~${_str(np / (frameTime) * 100)}%)", perfc(np)),
],
),
),
+25 -33
View File
@@ -75,14 +75,16 @@ class DevNetworkRequests extends BasePage {
RequestMethod.delete => Text("DELETE"),
RequestMethod.newHttpClient ||
RequestMethod.newHttpIOClient ||
RequestMethod.newProxySocket => null,
RequestMethod.newProxySocket =>
null,
},
title: Text(item.time.toIso8601String()),
subtitle: switch (item.method) {
RequestMethod.get ||
RequestMethod.post ||
RequestMethod.put ||
RequestMethod.delete => Text("${item.uri}"),
RequestMethod.delete =>
Text("${item.uri}"),
RequestMethod.newHttpClient => Text("newHttpClient"),
RequestMethod.newHttpIOClient => Text("newHttpIOClient"),
RequestMethod.newProxySocket => Text("newProxySocket"),
@@ -115,35 +117,26 @@ class DevRequestDetails extends BasePage {
children: [
_sectionTitle("Time"),
SelectableText(req.time.toString()),
_sectionTitle("Method"),
SelectableText(req.method.toString()),
_sectionTitle("URI"),
SelectableText(req.uri?.toString() ?? "null"),
_sectionTitle("Network"),
SelectableText(req.network.toString()),
if (req.network == RequestNetwork.tor)
...[
_sectionTitle("Tor socks server"),
SelectableText(CakeTor.instance.runtimeType.toString()),
_sectionTitle("Tor socks details"),
SelectableText(CakeTor.instance.toString()),
],
if (req.network == RequestNetwork.tor) ...[
_sectionTitle("Tor socks server"),
SelectableText(CakeTor.instance.runtimeType.toString()),
_sectionTitle("Tor socks details"),
SelectableText(CakeTor.instance.toString()),
],
_sectionTitle("Body (as UTF-8)"),
SelectableText(_tryDecodeBody(req.body)),
_buildJsonExplorer(context, _tryDecodeBody(req.body)),
_sectionTitle("Response"),
SelectableText(req.response?.body ?? "null"),
_buildJsonExplorer(context, req.response?.body ?? "{}"),
_sectionTitle("Error"),
SelectableText(req.error ?? "No error"),
_sectionTitle("Stack Trace"),
SelectableText(req.trace.toString()),
],
@@ -152,22 +145,21 @@ class DevRequestDetails extends BasePage {
Widget _buildJsonExplorer(BuildContext context, String body) {
try {
final jsonData = json.decode(body);
return PrimaryButton(
text: "View JSON",
color: Colors.blue,
textColor: Colors.white,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return JsonExplorerPage(data: jsonData, title: "body");
},
),
);
},
);
final jsonData = json.decode(body);
return PrimaryButton(
text: "View JSON",
color: Colors.blue,
textColor: Colors.white,
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return JsonExplorerPage(data: jsonData, title: "body");
},
),
);
},
);
} catch (e) {
return SelectableText("Invalid JSON: $e");
}
+8 -9
View File
@@ -19,21 +19,20 @@ class DevQRToolsPage extends BasePage {
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: textCtrl,
maxLines: 8,
onChanged: (value) {
viewModel.input = value;
}
),
controller: textCtrl,
maxLines: 8,
onChanged: (value) {
viewModel.input = value;
}),
Observer(
builder: (_) {
return Expanded(
child: JsonExplorer(data: viewModel.data, title: "result"),
);
child: JsonExplorer(data: viewModel.data, title: "result"),
);
},
),
],
),
);
}
}
}
@@ -38,10 +38,14 @@ class DevSecurePreferencesPage extends BasePage {
Clipboard.setData(ClipboardData(text: key + ": " + values[key].toString()));
},
title: switch (type) {
PreferenceType.bool => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.blue)),
PreferenceType.int => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.green)),
PreferenceType.double => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.yellow)),
PreferenceType.listString => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.purple)),
PreferenceType.bool => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.blue)),
PreferenceType.int => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.green)),
PreferenceType.double => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.yellow)),
PreferenceType.listString => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.purple)),
PreferenceType.string => Text(key),
PreferenceType.unknown => Text(key),
},
@@ -49,9 +53,12 @@ class DevSecurePreferencesPage extends BasePage {
PreferenceType.bool => Text("bool: ${values[key]}"),
PreferenceType.int => Text("int: ${values[key]}"),
PreferenceType.double => Text("double: ${values[key]}"),
PreferenceType.listString => values[key].isEmpty as bool ? Text("listString: []") : Text("listString:\n- ${values[key].join("\n- ")}"),
PreferenceType.listString => values[key].isEmpty as bool
? Text("listString: []")
: Text("listString:\n- ${values[key].join("\n- ")}"),
PreferenceType.string => Text("string: ${values[key]}"),
PreferenceType.unknown => Text("UNKNOWN(${values[key].runtimeType}): ${values[key]}"),
PreferenceType.unknown =>
Text("UNKNOWN(${values[key].runtimeType}): ${values[key]}"),
},
);
},
@@ -59,5 +66,4 @@ class DevSecurePreferencesPage extends BasePage {
},
);
}
}
}
@@ -50,10 +50,14 @@ class DevSharedPreferencesPage extends BasePage {
_showEditDialog(context, key, type, values[key]);
},
title: switch (type) {
PreferenceType.bool => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.blue)),
PreferenceType.int => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.green)),
PreferenceType.double => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.yellow)),
PreferenceType.listString => Text(key, style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.purple)),
PreferenceType.bool => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.blue)),
PreferenceType.int => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.green)),
PreferenceType.double => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.yellow)),
PreferenceType.listString => Text(key,
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: Colors.purple)),
PreferenceType.string => Text(key),
PreferenceType.unknown => Text(key),
},
@@ -61,9 +65,12 @@ class DevSharedPreferencesPage extends BasePage {
PreferenceType.bool => Text("bool: ${values[key]}"),
PreferenceType.int => Text("int: ${values[key]}"),
PreferenceType.double => Text("double: ${values[key]}"),
PreferenceType.listString => values[key].isEmpty as bool ? Text("listString: []") : Text("listString:\n- ${values[key].join("\n- ")}"),
PreferenceType.listString => values[key].isEmpty as bool
? Text("listString: []")
: Text("listString:\n- ${values[key].join("\n- ")}"),
PreferenceType.string => Text("string: ${values[key]}"),
PreferenceType.unknown => Text("UNKNOWN(${values[key].runtimeType}): ${values[key]}"),
PreferenceType.unknown =>
Text("UNKNOWN(${values[key].runtimeType}): ${values[key]}"),
},
);
},
@@ -72,12 +79,14 @@ class DevSharedPreferencesPage extends BasePage {
);
}
void _showEditDialog(BuildContext context, String key, PreferenceType type, dynamic currentValue) {
void _showEditDialog(
BuildContext context, String key, PreferenceType type, dynamic currentValue) {
dynamic newValue = currentValue;
bool isListString = type == PreferenceType.listString;
List<String> listItems = isListString ? List<String>.from(currentValue as Iterable<dynamic>) : [];
TextEditingController textController = TextEditingController(
text: isListString ? '' : currentValue?.toString() ?? '');
List<String> listItems =
isListString ? List<String>.from(currentValue as Iterable<dynamic>) : [];
TextEditingController textController =
TextEditingController(text: isListString ? '' : currentValue?.toString() ?? '');
showDialog(
context: context,
@@ -91,10 +100,10 @@ class DevSharedPreferencesPage extends BasePage {
height: double.maxFinite,
child: SingleChildScrollView(
child: _buildDialogContent(
type,
newValue,
listItems,
textController,
type,
newValue,
listItems,
textController,
(value) => setState(() => newValue = value),
(items) => setState(() => listItems = items),
),
@@ -116,12 +125,7 @@ class DevSharedPreferencesPage extends BasePage {
child: Text('Save'),
onPressed: () async {
if (_validateAndUpdateValue(
context,
type,
textController,
listItems,
(value) => newValue = value
)) {
context, type, textController, listItems, (value) => newValue = value)) {
await viewModel.set(key, type, newValue);
Navigator.of(context).pop();
}
@@ -210,9 +214,8 @@ class DevSharedPreferencesPage extends BasePage {
BaseTextFormField(
controller: controller,
hintText: label,
keyboardType: isInteger
? TextInputType.number
: TextInputType.numberWithOptions(decimal: true),
keyboardType:
isInteger ? TextInputType.number : TextInputType.numberWithOptions(decimal: true),
inputFormatters: isInteger
? [FilteringTextInputFormatter.digitsOnly]
: [FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*$'))],
@@ -222,7 +225,7 @@ class DevSharedPreferencesPage extends BasePage {
}
Widget _buildListEditor(
List<String> items,
List<String> items,
TextEditingController controller,
Function(List<String>) onListChanged,
) {
@@ -358,7 +361,8 @@ class DevSharedPreferencesPage extends BasePage {
DropdownMenuItem(value: PreferenceType.bool, child: Text('Boolean')),
DropdownMenuItem(value: PreferenceType.int, child: Text('Integer')),
DropdownMenuItem(value: PreferenceType.double, child: Text('Double')),
DropdownMenuItem(value: PreferenceType.listString, child: Text('List of Strings')),
DropdownMenuItem(
value: PreferenceType.listString, child: Text('List of Strings')),
],
onChanged: (value) {
if (value != null) {
@@ -384,14 +388,17 @@ class DevSharedPreferencesPage extends BasePage {
return;
}
viewModel.set(keyController.text, selectedType, switch (selectedType) {
PreferenceType.bool => false,
PreferenceType.int => 0,
PreferenceType.double => 0.0,
PreferenceType.string => '',
PreferenceType.listString => [],
PreferenceType.unknown => null,
});
viewModel.set(
keyController.text,
selectedType,
switch (selectedType) {
PreferenceType.bool => false,
PreferenceType.int => 0,
PreferenceType.double => 0.0,
PreferenceType.string => '',
PreferenceType.listString => [],
PreferenceType.unknown => null,
});
Navigator.of(context).pop();
},
),