format dart files

formats all dart files using `dart format .` from the root project dir

this makes the code style repeatable by new contributors and makes PR review easier
This commit is contained in:
446564
2026-02-04 08:32:35 -08:00
parent 488a286701
commit b34d684e67
66 changed files with 2882 additions and 1848 deletions
+64 -50
View File
@@ -8,13 +8,9 @@ import '../connector/meshcore_protocol.dart';
import '../models/contact.dart';
import '../widgets/snr_indicator.dart';
import '../l10n/l10n.dart';
class PathTraceDialog extends StatefulWidget {
const PathTraceDialog({
super.key,
required this.title,
required this.path,
});
class PathTraceDialog extends StatefulWidget {
const PathTraceDialog({super.key, required this.title, required this.path});
final String title;
final Uint8List path;
@@ -31,7 +27,7 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
bool _failed2Loaded = false;
bool _hasData = false;
Uint8List _pathData = Uint8List(0);
Uint8List _snrData = Uint8List(0) ;
Uint8List _snrData = Uint8List(0);
Map<int, Contact> _pathContacts = {};
@override
@@ -49,13 +45,13 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
}
Future<void> _doPathTrace() async {
if(mounted) {
if (mounted) {
setState(() {
_isLoading = true;
_failed2Loaded = false;
});
}
final connector = Provider.of<MeshCoreConnector>(context, listen: false);
final frame = buildTraceReq(
DateTime.now().millisecondsSinceEpoch ~/ 1000,
@@ -92,18 +88,19 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
}
// Check if it's a binary response
if (code == pushCodeTraceData && listEquals(frame.sublist(4, 8), tagData)) {
if (code == pushCodeTraceData &&
listEquals(frame.sublist(4, 8), tagData)) {
_timeoutTimer?.cancel();
if (!mounted) return;
frameBuffer.skipBytes(3); //reserved + path length + flag
if(listEquals(frameBuffer.readBytes(4), tagData)){
if (listEquals(frameBuffer.readBytes(4), tagData)) {
_handleTraceResponse(frame);
}
}
});
}
Future<void> _handleTraceResponse(Uint8List frame)async {
Future<void> _handleTraceResponse(Uint8List frame) async {
final connector = Provider.of<MeshCoreConnector>(context, listen: false);
final buffer = BufferReader(frame);
@@ -116,9 +113,7 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
Map<int, Contact> pathContacts = {};
connector.contacts.where((c) => c.type != advTypeChat).forEach((
repeater,
) {
connector.contacts.where((c) => c.type != advTypeChat).forEach((repeater) {
for (var neighbourData in pathData) {
if (listEquals(
repeater.publicKey.sublist(0, 1),
@@ -143,21 +138,26 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
if (index == 0) {
return context.l10n.pathTrace_you;
} else {
return _pathContacts[_pathData[_pathData.length - 1]]?.name ?? "0x${_pathData[_pathData.length - 1].toRadixString(16).toUpperCase()}";
return _pathContacts[_pathData[_pathData.length - 1]]?.name ??
"0x${_pathData[_pathData.length - 1].toRadixString(16).toUpperCase()}";
}
} else {
return _pathContacts[_pathData[index-1]]?.name ?? "0x${_pathData[index-1].toRadixString(16).toUpperCase()}";
return _pathContacts[_pathData[index - 1]]?.name ??
"0x${_pathData[index - 1].toRadixString(16).toUpperCase()}";
}
}
String formatDirectionSubText(int index) {
if (index == 0 || index == _snrData.length - 1) {
if (index == 0) {
return _pathContacts[_pathData[0]]?.name ?? "0x${_pathData[0].toRadixString(16).toUpperCase()}";
return _pathContacts[_pathData[0]]?.name ??
"0x${_pathData[0].toRadixString(16).toUpperCase()}";
} else {
return context.l10n.pathTrace_you;
}
} else {
return _pathContacts[_pathData[index]]?.name ?? "0x${_pathData[index].toRadixString(16).toUpperCase()}";
return _pathContacts[_pathData[index]]?.name ??
"0x${_pathData[index].toRadixString(16).toUpperCase()}";
}
}
@@ -165,47 +165,61 @@ class _PathTraceDialogState extends State<PathTraceDialog> {
Widget build(BuildContext context) {
final l10n = context.l10n;
return AlertDialog(
title: Column( children: [
FittedBox(fit: BoxFit.scaleDown, child: Text(widget.title, style: const TextStyle(fontSize: 24))),
if(_failed2Loaded)
Text(l10n.pathTrace_failed, style: TextStyle(fontSize: 14, color: Theme.of(context).colorScheme.error),),
title: Column(
children: [
FittedBox(
fit: BoxFit.scaleDown,
child: Text(widget.title, style: const TextStyle(fontSize: 24)),
),
if (_failed2Loaded)
Text(
l10n.pathTrace_failed,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).colorScheme.error,
),
),
],
),
content: SafeArea(
child: RefreshIndicator(
onRefresh: _doPathTrace,
child: !_hasData
? Center(
child: Text(l10n.pathTrace_notAvailable),
)
: ListView.builder(
itemCount: _snrData.length,
itemBuilder: (context, index) {
return Column(
children: [
ListTile(
leading: index >= _snrData.length / 2 ? Icon(Icons.call_received) : Icon(Icons.call_made),
title: Text(
formatDirectionText(index), style: const TextStyle(fontSize: 14),
),
subtitle: Text(
formatDirectionSubText(index),
style: const TextStyle(fontSize: 14),
),
trailing: SNRIcon(snr: _snrData[index].toSigned(8) / 4.0),
onTap: () {
// Handle item tap
},
? Center(child: Text(l10n.pathTrace_notAvailable))
: ListView.builder(
itemCount: _snrData.length,
itemBuilder: (context, index) {
return Column(
children: [
ListTile(
leading: index >= _snrData.length / 2
? Icon(Icons.call_received)
: Icon(Icons.call_made),
title: Text(
formatDirectionText(index),
style: const TextStyle(fontSize: 14),
),
if (index < _snrData.length - 1) const Divider(height: 0.0),
],
);
},
),
subtitle: Text(
formatDirectionSubText(index),
style: const TextStyle(fontSize: 14),
),
trailing: SNRIcon(
snr: _snrData[index].toSigned(8) / 4.0,
),
onTap: () {
// Handle item tap
},
),
if (index < _snrData.length - 1)
const Divider(height: 0.0),
],
);
},
),
),
),
actions: [
IconButton(
IconButton(
icon: _isLoading
? const SizedBox(
width: 20,