Skip to content

Commit 3e953eb

Browse files
committed
format with dart
format only, using `dart format .` adds check in ci to confirm formatting
1 parent 2a5ae74 commit 3e953eb

61 files changed

Lines changed: 5386 additions & 2866 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ jobs:
2121

2222
- run: flutter pub get
2323
- run: dart run build_runner build --delete-conflicting-outputs
24+
- run: dart format --output=none --set-exit-if-changed .
2425
- run: flutter analyze
2526
- run: flutter test

‎bin/test_message.dart‎

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,22 @@ class PayloadType {
107107
class CryptoService {
108108
/// Fixed key for "Public" channel
109109
static final Uint8List publicChannelFixedKey = Uint8List.fromList([
110-
0x8b, 0x33, 0x87, 0xe9, 0xc5, 0xcd, 0xea, 0x6a,
111-
0xc9, 0xe5, 0xed, 0xba, 0xa1, 0x15, 0xcd, 0x72,
110+
0x8b,
111+
0x33,
112+
0x87,
113+
0xe9,
114+
0xc5,
115+
0xcd,
116+
0xea,
117+
0x6a,
118+
0xc9,
119+
0xe5,
120+
0xed,
121+
0xba,
122+
0xa1,
123+
0x15,
124+
0xcd,
125+
0x72,
112126
]);
113127

114128
/// Derive a 16-byte channel key from a hashtag channel name using SHA-256
@@ -228,8 +242,10 @@ class PacketMetadata {
228242

229243
final int header = raw[0];
230244
final int routeType = header & PacketHeader.routeMask;
231-
final int payloadType = (header >> PacketHeader.typeShift) & PacketHeader.typeMask;
232-
final int protocolVersion = (header >> PacketHeader.verShift) & PacketHeader.verMask;
245+
final int payloadType =
246+
(header >> PacketHeader.typeShift) & PacketHeader.typeMask;
247+
final int protocolVersion =
248+
(header >> PacketHeader.verShift) & PacketHeader.verMask;
233249

234250
// Calculate offset for Path Length based on route type
235251
int pathLengthOffset = 1;
@@ -427,9 +443,12 @@ void main(List<String> arguments) {
427443

428444
// Print packet metadata
429445
print('PACKET METADATA');
430-
print(' Header: 0x${metadata.header.toRadixString(16).padLeft(2, '0').toUpperCase()}');
431-
print(' Route Type: ${RouteType.getName(metadata.routeType)} (0x${metadata.routeType.toRadixString(16).padLeft(2, '0')})');
432-
print(' Payload Type: ${PayloadType.getName(metadata.payloadType)} (0x${metadata.payloadType.toRadixString(16).padLeft(2, '0')})');
446+
print(
447+
' Header: 0x${metadata.header.toRadixString(16).padLeft(2, '0').toUpperCase()}');
448+
print(
449+
' Route Type: ${RouteType.getName(metadata.routeType)} (0x${metadata.routeType.toRadixString(16).padLeft(2, '0')})');
450+
print(
451+
' Payload Type: ${PayloadType.getName(metadata.payloadType)} (0x${metadata.payloadType.toRadixString(16).padLeft(2, '0')})');
433452
print(' Protocol Version: ${metadata.protocolVersion}');
434453
print(' Path Length: ${metadata.pathLength} bytes');
435454

@@ -444,10 +463,12 @@ void main(List<String> arguments) {
444463
print(' Path: (empty)');
445464
}
446465

447-
print(' Encrypted Payload: ${formatHex(metadata.encryptedPayload)} (${metadata.encryptedPayload.length} bytes)');
466+
print(
467+
' Encrypted Payload: ${formatHex(metadata.encryptedPayload)} (${metadata.encryptedPayload.length} bytes)');
448468

449469
if (metadata.channelHash != null) {
450-
print(' Channel Hash: 0x${metadata.channelHash!.toRadixString(16).padLeft(2, '0').toUpperCase()}');
470+
print(
471+
' Channel Hash: 0x${metadata.channelHash!.toRadixString(16).padLeft(2, '0').toUpperCase()}');
451472
}
452473
print('');
453474

@@ -514,7 +535,8 @@ void main(List<String> arguments) {
514535
print('');
515536
print(' Known channel hashes:');
516537
for (final entry in channels.entries) {
517-
print(' 0x${entry.key.toRadixString(16).padLeft(2, '0').toUpperCase()} -> ${entry.value.channelName}');
538+
print(
539+
' 0x${entry.key.toRadixString(16).padLeft(2, '0').toUpperCase()} -> ${entry.value.channelName}');
518540
}
519541
printValidationResults(steps, false, 'Unknown channel hash');
520542
return;

‎lib/main.dart‎

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ Future<void> _requestPermissions() async {
114114
Future<void> _requestiOSPermissions() async {
115115
// Note: Location permission is now requested AFTER showing the prominent disclosure
116116
// dialog in MainScaffold (required for Google Play compliance)
117-
debugLog('[APP] iOS: Skipping location permission (handled after disclosure)');
117+
debugLog(
118+
'[APP] iOS: Skipping location permission (handled after disclosure)');
118119

119120
// Trigger Core Bluetooth authorization by checking adapter state
120121
// This will cause iOS to show the Bluetooth permission prompt if not already granted
@@ -132,7 +133,8 @@ Future<void> _requestiOSPermissions() async {
132133
.where((state) => state == fbp.BluetoothAdapterState.on)
133134
.first
134135
.timeout(const Duration(seconds: 3), onTimeout: () {
135-
debugLog('[APP] iOS: Bluetooth authorization timeout (user may have denied or BT is off)');
136+
debugLog(
137+
'[APP] iOS: Bluetooth authorization timeout (user may have denied or BT is off)');
136138
return fbp.BluetoothAdapterState.off;
137139
});
138140
}
@@ -165,36 +167,39 @@ Future<void> _requestAndroidPermissions() async {
165167

166168
// Dark theme - Tailwind Slate palette
167169
const darkColorScheme = ColorScheme.dark(
168-
primary: Color(0xFF059669), // emerald-600 (main actions)
170+
primary: Color(0xFF059669), // emerald-600 (main actions)
169171
onPrimary: Colors.white,
170-
secondary: Color(0xFF0284C7), // sky-600 (TX ping)
172+
secondary: Color(0xFF0284C7), // sky-600 (TX ping)
171173
onSecondary: Colors.white,
172-
tertiary: Color(0xFF4F46E5), // indigo-600 (auto modes)
174+
tertiary: Color(0xFF4F46E5), // indigo-600 (auto modes)
173175
onTertiary: Colors.white,
174-
surface: Color(0xFF1E293B), // slate-800 (cards/panels)
175-
onSurface: Color(0xFFF1F5F9), // slate-100 (primary text)
176-
onSurfaceVariant: Color(0xFFCBD5E1), // slate-300 (muted text, brighter for contrast)
176+
surface: Color(0xFF1E293B), // slate-800 (cards/panels)
177+
onSurface: Color(0xFFF1F5F9), // slate-100 (primary text)
178+
onSurfaceVariant:
179+
Color(0xFFCBD5E1), // slate-300 (muted text, brighter for contrast)
177180
surfaceContainerHighest: Color(0xFF0F172A), // slate-900 (main bg)
178-
outline: Color(0xFF334155), // slate-700 (borders)
179-
error: Color(0xFFF87171), // red-400
181+
outline: Color(0xFF334155), // slate-700 (borders)
182+
error: Color(0xFFF87171), // red-400
180183
onError: Colors.white,
181184
);
182185

183186
// Light theme - Tailwind Slate palette (inverted)
184187
// Note: Using darker grays for better text contrast
185188
const lightColorScheme = ColorScheme.light(
186-
primary: Color(0xFF059669), // emerald-600
189+
primary: Color(0xFF059669), // emerald-600
187190
onPrimary: Colors.white,
188-
secondary: Color(0xFF0284C7), // sky-600
191+
secondary: Color(0xFF0284C7), // sky-600
189192
onSecondary: Colors.white,
190-
tertiary: Color(0xFF4F46E5), // indigo-600
193+
tertiary: Color(0xFF4F46E5), // indigo-600
191194
onTertiary: Colors.white,
192-
surface: Color(0xFFF8FAFC), // slate-50 (cards/panels)
193-
onSurface: Color(0xFF0F172A), // slate-900 (primary text - darker for contrast)
194-
onSurfaceVariant: Color(0xFF475569), // slate-600 (muted text - darker for readability)
195+
surface: Color(0xFFF8FAFC), // slate-50 (cards/panels)
196+
onSurface:
197+
Color(0xFF0F172A), // slate-900 (primary text - darker for contrast)
198+
onSurfaceVariant:
199+
Color(0xFF475569), // slate-600 (muted text - darker for readability)
195200
surfaceContainerHighest: Color(0xFFFFFFFF), // white (main bg)
196-
outline: Color(0xFFCBD5E1), // slate-300 (borders)
197-
error: Color(0xFFDC2626), // red-600
201+
outline: Color(0xFFCBD5E1), // slate-300 (borders)
202+
error: Color(0xFFDC2626), // red-600
198203
onError: Colors.white,
199204
);
200205

@@ -206,9 +211,8 @@ class MeshMapperApp extends StatelessWidget {
206211
@override
207212
Widget build(BuildContext context) {
208213
// Create platform-appropriate Bluetooth service
209-
final BluetoothService bluetoothService = kIsWeb
210-
? WebBluetoothService()
211-
: MobileBluetoothService();
214+
final BluetoothService bluetoothService =
215+
kIsWeb ? WebBluetoothService() : MobileBluetoothService();
212216

213217
return MultiProvider(
214218
providers: [
@@ -260,7 +264,8 @@ class _ThemedAppState extends State<_ThemedApp> {
260264
scaffoldBackgroundColor: const Color(0xFFF1F5F9), // slate-100
261265
appBarTheme: const AppBarTheme(
262266
backgroundColor: Color(0xFFF8FAFC), // slate-50
263-
foregroundColor: Color(0xFF0F172A), // slate-900 (darker for contrast)
267+
foregroundColor:
268+
Color(0xFF0F172A), // slate-900 (darker for contrast)
264269
),
265270
cardTheme: CardThemeData(
266271
color: const Color(0xFFF8FAFC), // slate-50

‎lib/models/api_queue_item.dart‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class ApiQueueItem extends HiveObject {
8787
longitude: longitude,
8888
timestamp: DateTime.fromMillisecondsSinceEpoch(timestamp * 1000),
8989
heardRepeats: heardRepeats,
90-
canUploadAfter: DateTime.now().millisecondsSinceEpoch, // Immediate — flush timer controls upload timing
90+
canUploadAfter: DateTime.now()
91+
.millisecondsSinceEpoch, // Immediate — flush timer controls upload timing
9192
externalAntenna: externalAntenna,
9293
noiseFloor: noiseFloor,
9394
power: power,
@@ -135,7 +136,8 @@ class ApiQueueItem extends HiveObject {
135136
double? power,
136137
}) {
137138
// Format: "repeaterId:nodeType:localSnr:localRssi:remoteSnr:pubkeyFull"
138-
final heardRepeats = '$repeaterId:$nodeType:${localSnr.toStringAsFixed(2)}:$localRssi:${remoteSnr.toStringAsFixed(2)}:$pubkeyFull';
139+
final heardRepeats =
140+
'$repeaterId:$nodeType:${localSnr.toStringAsFixed(2)}:$localRssi:${remoteSnr.toStringAsFixed(2)}:$pubkeyFull';
139141
return ApiQueueItem(
140142
type: 'DISC',
141143
latitude: latitude,
@@ -163,7 +165,8 @@ class ApiQueueItem extends HiveObject {
163165
int? noiseFloor,
164166
double? power,
165167
}) {
166-
final heardRepeats = '$repeaterId:${localSnr.toStringAsFixed(2)}:$localRssi:${remoteSnr.toStringAsFixed(2)}';
168+
final heardRepeats =
169+
'$repeaterId:${localSnr.toStringAsFixed(2)}:$localRssi:${remoteSnr.toStringAsFixed(2)}';
167170
return ApiQueueItem(
168171
type: 'TRACE',
169172
latitude: latitude,
@@ -249,7 +252,8 @@ class ApiQueueItem extends HiveObject {
249252
'local_rssi': parts.length > 3 ? int.tryParse(parts[3]) ?? 0 : 0,
250253
'remote_snr': parts.length > 4 ? double.tryParse(parts[4]) ?? 0.0 : 0.0,
251254
'public_key': parts.length > 5 ? parts[5] : '',
252-
'timestamp': timestamp.millisecondsSinceEpoch ~/ 1000, // Unix timestamp in seconds
255+
'timestamp': timestamp.millisecondsSinceEpoch ~/
256+
1000, // Unix timestamp in seconds
253257
'external_antenna': externalAntenna,
254258
'power': power != null ? '${power!.toStringAsFixed(1)}w' : null,
255259
};
@@ -261,7 +265,8 @@ class ApiQueueItem extends HiveObject {
261265
'lon': longitude,
262266
'noisefloor': noiseFloor,
263267
'heard_repeats': heardRepeats,
264-
'timestamp': timestamp.millisecondsSinceEpoch ~/ 1000, // Unix timestamp in seconds
268+
'timestamp':
269+
timestamp.millisecondsSinceEpoch ~/ 1000, // Unix timestamp in seconds
265270
'external_antenna': externalAntenna,
266271
'power': power != null ? '${power!.toStringAsFixed(1)}w' : null,
267272
};
@@ -281,7 +286,8 @@ class ApiQueueItem extends HiveObject {
281286
}
282287

283288
/// Check if item is eligible for upload based on canUploadAfter
284-
bool get isUploadEligible => DateTime.now().millisecondsSinceEpoch >= canUploadAfter;
289+
bool get isUploadEligible =>
290+
DateTime.now().millisecondsSinceEpoch >= canUploadAfter;
285291

286292
/// Mark as retried
287293
void markRetried() {
@@ -291,5 +297,6 @@ class ApiQueueItem extends HiveObject {
291297
}
292298

293299
@override
294-
String toString() => 'ApiQueueItem($type, $latitude, $longitude, retries=$retryCount)';
300+
String toString() =>
301+
'ApiQueueItem($type, $latitude, $longitude, retries=$retryCount)';
295302
}

‎lib/models/connection_state.dart‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
enum ConnectionStatus {
33
/// Not connected to any device
44
disconnected,
5-
5+
66
/// Currently scanning for devices
77
scanning,
8-
8+
99
/// Connecting to device
1010
connecting,
11-
11+
1212
/// Connected and ready
1313
connected,
14-
14+
1515
/// Connection error occurred
1616
error,
1717
}
@@ -27,31 +27,31 @@ enum ConnectionStep {
2727

2828
/// Step 1: BLE GATT connect
2929
bleConnecting,
30-
30+
3131
/// Step 2: Protocol handshake
3232
protocolHandshake,
33-
33+
3434
/// Step 3: Device info query
3535
deviceQuery,
36-
36+
3737
/// Step 4: Device identification (match device model for display/reporting)
3838
powerConfiguration,
39-
39+
4040
/// Step 5: Time synchronization
4141
timeSync,
42-
42+
4343
/// Step 6: API slot acquisition
4444
slotAcquisition,
45-
45+
4646
/// Step 7: Channel setup (#wardriving)
4747
channelSetup,
48-
48+
4949
/// Step 8: GPS initialization
5050
gpsInit,
51-
51+
5252
/// Step 9: Fully connected and ready
5353
connected,
54-
54+
5555
/// Error state
5656
error,
5757
}
@@ -60,13 +60,13 @@ enum ConnectionStep {
6060
enum GpsStatus {
6161
/// GPS permissions not granted
6262
permissionDenied,
63-
63+
6464
/// GPS is disabled on device
6565
disabled,
66-
66+
6767
/// Searching for GPS signal
6868
searching,
69-
69+
7070
/// GPS lock acquired
7171
locked,
7272

‎lib/models/device_model.dart‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
/// Represents a MeshCore device model with its power configuration.
2-
///
2+
///
33
/// This maps to the device-models.json database from the WebClient repo.
44
/// Power configuration is critical for PA amplifier models to prevent hardware damage.
55
class DeviceModel {
66
/// Full manufacturer string reported by device (e.g., "Ikoka Stick-E22-30dBm (Xiao_nrf52)")
77
final String manufacturer;
8-
8+
99
/// Short display name (e.g., "Ikoka Stick")
1010
final String shortName;
11-
11+
1212
/// Power setting for wardrive.js (0.3, 0.6, 1.0, 2.0)
1313
/// CRITICAL: PA amplifier models require exact values
1414
final double power;
15-
15+
1616
/// Hardware platform (nrf52, esp32, esp32-s3, etc.)
1717
final String platform;
18-
18+
1919
/// Firmware TX power setting in dBm
2020
final int txPower;
21-
21+
2222
/// Additional notes about the device
2323
final String notes;
2424

@@ -55,7 +55,8 @@ class DeviceModel {
5555
}
5656

5757
@override
58-
String toString() => 'DeviceModel($shortName, power=$power, txPower=$txPower)';
58+
String toString() =>
59+
'DeviceModel($shortName, power=$power, txPower=$txPower)';
5960
}
6061

6162
/// Container for the full device models database

0 commit comments

Comments
 (0)