Skip to content

Commit f12dc1c

Browse files
committed
new formatter
1 parent a6b8065 commit f12dc1c

File tree

9 files changed

+60
-81
lines changed

9 files changed

+60
-81
lines changed

lib/services/nt_connection.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ class NTConnection {
167167
_ntClient.setServerBaseAddreess(ipAddress);
168168
}
169169

170-
NT4Subscription subscribe(String topic, [double period = 0.1]) {
170+
NT4Subscription subscribe(
171+
String topic, [
172+
double period = 0.1,
173+
NT4StructMeta? ntStructMeta,
174+
]) {
171175
NT4SubscriptionOptions subscriptionOptions = NT4SubscriptionOptions(
172176
periodicRateSeconds: period,
177+
structMeta: ntStructMeta,
173178
);
174179

175180
int hashCode = Object.hash(topic, subscriptionOptions);

lib/services/struct_schemas/nt_struct.dart

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ class SchemaInfo {
5555
return;
5656
}
5757

58-
logger.debug(
59-
'Adding schema: $name, $schema',
60-
);
58+
logger.debug('Adding schema: $name, $schema');
6159

6260
_schemas[name] = schema;
6361
}
@@ -92,14 +90,9 @@ class NTFieldSchema {
9290
final String field;
9391
final NT4Type type;
9492

95-
NTFieldSchema({
96-
required this.field,
97-
required this.type,
98-
});
93+
NTFieldSchema({required this.field, required this.type});
9994

100-
static NTFieldSchema fromJson(
101-
Map<String, dynamic> json,
102-
) {
95+
static NTFieldSchema fromJson(Map<String, dynamic> json) {
10396
return NTFieldSchema(
10497
field: json['name'] ?? json['field'],
10598
type: NT4Type.parse('struct:${json['type']}'),
@@ -110,30 +103,18 @@ class NTFieldSchema {
110103
NT4Type fieldType = NT4Type.parse(type);
111104

112105
if (fieldType.leaf.isStruct) {
113-
return NTFieldSchema(
114-
field: name,
115-
type: fieldType,
116-
);
106+
return NTFieldSchema(field: name, type: fieldType);
117107
} else {
118-
return NTFieldSchema(
119-
field: name,
120-
type: fieldType,
121-
);
108+
return NTFieldSchema(field: name, type: fieldType);
122109
}
123110
}
124111

125112
NTFieldSchema clone() {
126-
return NTFieldSchema(
127-
field: field,
128-
type: type,
129-
);
113+
return NTFieldSchema(field: field, type: type);
130114
}
131115

132116
Map<String, dynamic> toJson() {
133-
return {
134-
'field': field,
135-
'type': type.serialize(),
136-
};
117+
return {'field': field, 'type': type.serialize()};
137118
}
138119

139120
NTStructSchema? get substruct =>
@@ -146,15 +127,10 @@ class NTStructSchema {
146127
final String name;
147128
final List<NTFieldSchema> fields;
148129

149-
NTStructSchema({
150-
required this.name,
151-
required String schema,
152-
}) : fields = _tryParseSchema(name, schema);
130+
NTStructSchema({required this.name, required String schema})
131+
: fields = _tryParseSchema(name, schema);
153132

154-
NTStructSchema.raw({
155-
required this.name,
156-
required this.fields,
157-
});
133+
NTStructSchema.raw({required this.name, required this.fields});
158134

159135
NTFieldSchema? operator [](String key) {
160136
for (final field in fields) {
@@ -209,9 +185,10 @@ class NTStructSchema {
209185
static NTStructSchema fromJson(Map<String, dynamic> json) {
210186
return NTStructSchema.raw(
211187
name: json['name'] ?? json['type'],
212-
fields: (tryCast<List<dynamic>>(json['fields']) ?? [])
213-
.map((field) => NTFieldSchema.fromJson(tryCast(field) ?? {}))
214-
.toList(),
188+
fields:
189+
(tryCast<List<dynamic>>(json['fields']) ?? [])
190+
.map((field) => NTFieldSchema.fromJson(tryCast(field) ?? {}))
191+
.toList(),
215192
);
216193
}
217194
}
@@ -256,10 +233,7 @@ class NTStruct {
256233
late final Map<String, NTStructValue> values;
257234
late final int consumed;
258235

259-
NTStruct({
260-
required this.schema,
261-
required Uint8List data,
262-
}) {
236+
NTStruct({required this.schema, required Uint8List data}) {
263237
var (consumed, values) = _parseData(schema, data);
264238
this.values = values;
265239
this.consumed = consumed;
@@ -284,7 +258,9 @@ class NTStruct {
284258
}
285259

286260
static (int, Map<String, NTStructValue>) _parseData(
287-
NTStructSchema schema, Uint8List data) {
261+
NTStructSchema schema,
262+
Uint8List data,
263+
) {
288264
Map<String, NTStructValue> values = {};
289265
int offset = 0;
290266

@@ -316,33 +292,39 @@ class NTStruct {
316292
}
317293

318294
static (int, NTStructValue) _parseValueInner(
319-
NTFieldSchema field, Uint8List data) {
295+
NTFieldSchema field,
296+
Uint8List data,
297+
) {
320298
if (field.type.fragment == NT4TypeFragment.boolean) {
321299
return (1, NTStructValue.fromBool(data[0] != 0));
322300
} else if (field.type.fragment == NT4TypeFragment.int32) {
323301
return (
324302
4,
325303
NTStructValue.fromInt(
326-
data.buffer.asByteData().getInt32(0, Endian.little))
304+
data.buffer.asByteData().getInt32(0, Endian.little),
305+
),
327306
);
328307
} else if (field.type.fragment == NT4TypeFragment.float32) {
329308
return (
330309
4,
331310
NTStructValue.fromDouble(
332-
data.buffer.asByteData().getFloat32(0, Endian.little))
311+
data.buffer.asByteData().getFloat32(0, Endian.little),
312+
),
333313
);
334314
} else if (field.type.fragment == NT4TypeFragment.float64) {
335315
return (
336316
8,
337317
NTStructValue.fromDouble(
338-
data.buffer.asByteData().getFloat64(0, Endian.little))
318+
data.buffer.asByteData().getFloat64(0, Endian.little),
319+
),
339320
);
340321
} else if (field.type.fragment == NT4TypeFragment.string) {
341322
int length = data.buffer.asByteData().getInt32(0, Endian.little);
342323
return (
343324
length + 4,
344325
NTStructValue.fromString(
345-
String.fromCharCodes(data.sublist(4, 4 + length)))
326+
String.fromCharCodes(data.sublist(4, 4 + length)),
327+
),
346328
);
347329
} else if (field.type.isStruct) {
348330
NTStructSchema? substruct = field.substruct;
@@ -351,10 +333,7 @@ class NTStruct {
351333
throw Exception('No schema found for struct: ${field.type.name}');
352334
}
353335

354-
NTStruct sub = NTStruct(
355-
schema: substruct,
356-
data: data,
357-
);
336+
NTStruct sub = NTStruct(schema: substruct, data: data);
358337

359338
return (sub.consumed, NTStructValue.fromStruct(sub));
360339
} else {
@@ -363,7 +342,10 @@ class NTStruct {
363342
}
364343

365344
static (int, NTStructValue<List<NTStructValue>>) _parseArray(
366-
NTFieldSchema field, Uint8List data, int length) {
345+
NTFieldSchema field,
346+
Uint8List data,
347+
int length,
348+
) {
367349
List<NTStructValue> values = [];
368350
int offset = 0;
369351

lib/widgets/dialog_widgets/layout_drag_tile.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class LayoutDragTile extends StatefulWidget {
1313

1414
final void Function(Offset globalPosition, LayoutContainerModel widget)
1515
onDragUpdate;
16-
1716
final void Function(LayoutContainerModel widget) onDragEnd;
1817

1918
final void Function() onRemoveWidget;

lib/widgets/draggable_containers/draggable_widget_container.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ class DraggableWidgetContainer extends StatelessWidget {
5757
allowFlippingWhileResizing: false,
5858
handleTapSize: 12,
5959
visibleHandles: const {},
60-
supportedDragDevices: PointerDeviceKind.values
61-
.whereNot((e) => e == PointerDeviceKind.trackpad)
62-
.toSet(),
63-
supportedResizeDevices: PointerDeviceKind.values
64-
.whereNot((e) => e == PointerDeviceKind.trackpad)
65-
.toSet(),
60+
supportedDragDevices:
61+
PointerDeviceKind.values
62+
.whereNot((e) => e == PointerDeviceKind.trackpad)
63+
.toSet(),
64+
supportedResizeDevices:
65+
PointerDeviceKind.values
66+
.whereNot((e) => e == PointerDeviceKind.trackpad)
67+
.toSet(),
6668
draggable: model.draggable,
6769
resizable: model.draggable,
6870
contentBuilder: (BuildContext context, Rect rect, Flip flip) {

lib/widgets/nt_widgets/multi_topic/field_widget.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ class FieldWidgetModel extends MultiTopicNTWidgetModel {
190190
_robotColor = Color(
191191
tryCast(jsonData['robot_color']) ?? Colors.red.toARGB32(),
192192
);
193-
_trajectoryColor =
194-
Color(tryCast(jsonData['trajectory_color']) ?? Colors.white.toARGB32());
193+
_trajectoryColor = Color(
194+
tryCast(jsonData['trajectory_color']) ?? Colors.white.toARGB32(),
195+
);
195196

196197
if (!FieldImages.hasField(_fieldGame)) {
197198
_fieldGame = _defaultGame;

lib/widgets/nt_widgets/single_topic/graph.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ class GraphModel extends SingleTopicNTWidgetModel {
9191
5.0;
9292
_minValue = tryCast(jsonData['min_value']);
9393
_maxValue = tryCast(jsonData['max_value']);
94-
_mainColor =
95-
Color(tryCast(jsonData['color']) ?? Colors.cyan.shade500.toARGB32());
94+
_mainColor = Color(
95+
tryCast(jsonData['color']) ?? Colors.cyan.shade500.toARGB32(),
96+
);
9697
_lineWidth = tryCast(jsonData['line_width']) ?? 2.0;
9798
}
9899

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: elastic_dashboard
22
description: A simple and modern dashboard for FRC.
3-
publish_to: 'none'
3+
publish_to: "none"
44
version: 2025.2.2
55

66
environment:
7-
sdk: '^3.7.0'
7+
sdk: "^3.7.0"
88

99
dependencies:
1010
animations: ^2.0.11

test/widgets/network_tree/networktables_tree_test.dart

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ void main() {
2121
testWidgets('Network Tables Tree with leading slashes', (widgetTester) async {
2222
NTConnection ntConnection = createMockOnlineNT4(
2323
virtualTopics: [
24-
NT4Topic(
25-
name: '/Testing/Integer',
26-
type: NT4Type.int(),
27-
properties: {},
28-
),
24+
NT4Topic(name: '/Testing/Integer', type: NT4Type.int(), properties: {}),
2925
NT4Topic(
3026
name: '/Testing/Double',
3127
type: NT4Type.double(),
@@ -78,11 +74,7 @@ void main() {
7874
) async {
7975
NTConnection ntConnection = createMockOnlineNT4(
8076
virtualTopics: [
81-
NT4Topic(
82-
name: 'Testing/Integer',
83-
type: NT4Type.int(),
84-
properties: {},
85-
),
77+
NT4Topic(name: 'Testing/Integer', type: NT4Type.int(), properties: {}),
8678
NT4Topic(
8779
name: 'Testing/Double',
8880
type: NT4Type.double(),
@@ -133,11 +125,7 @@ void main() {
133125
testWidgets('Network Tables Tree searching', (widgetTester) async {
134126
NTConnection ntConnection = createMockOnlineNT4(
135127
virtualTopics: [
136-
NT4Topic(
137-
name: '/Testing/Integer',
138-
type: NT4Type.int(),
139-
properties: {},
140-
),
128+
NT4Topic(name: '/Testing/Integer', type: NT4Type.int(), properties: {}),
141129
NT4Topic(
142130
name: '/Testing/Double',
143131
type: NT4Type.double(),

test/widgets/nt_widgets/single_topic/text_display_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ void main() {
223223
properties: {},
224224
),
225225
],
226+
virtualValues: {'Test/Display Value': 0},
226227
),
227228
preferences: preferences,
228229
ntStructMeta: null,

0 commit comments

Comments
 (0)