@@ -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
0 commit comments