Skip to content

Commit a98ba5d

Browse files
committed
Format code
1 parent 919b4f9 commit a98ba5d

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

lib/src/api/models/variables_model.dart

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ enum VariableType {
3434
image;
3535

3636
/// Returns a string representation of the variable type.
37-
String get label =>
38-
switch (this) {
37+
String get label => switch (this) {
3938
VariableType.integer => 'Integer',
4039
VariableType.text => 'Text',
4140
VariableType.decimal => 'Decimal',
@@ -56,10 +55,8 @@ enum VariableType {
5655
List() => VariableType.list,
5756
Map() => VariableType.map,
5857
String() => VariableType.text,
59-
_ =>
60-
throw UnsupportedError(
61-
'object type ${obj
62-
.runtimeType} is not supported. Cannot determine variable type'),
58+
_ => throw UnsupportedError(
59+
'object type ${obj.runtimeType} is not supported. Cannot determine variable type'),
6360
};
6461
}
6562

@@ -123,8 +120,7 @@ class VariableData
123120
Object? value = '',
124121
this.type = VariableType.text,
125122
Map<String, dynamic>? extra,
126-
})
127-
: value = sanitizeValueForVariableType(value, type).toString(),
123+
}) : value = sanitizeValueForVariableType(value, type).toString(),
128124
extra = extra ?? {};
129125

130126
/// Duplicate a [VariableData] with the given parameters.
@@ -164,8 +160,7 @@ class VariableData
164160

165161
/// Allows to convert a [VariableData] into [CanvasVariableData] with the
166162
/// given [canvasId].
167-
CanvasVariableData withCanvas(String canvasId) =>
168-
CanvasVariableData(
163+
CanvasVariableData withCanvas(String canvasId) => CanvasVariableData(
169164
id: id,
170165
canvasId: canvasId,
171166
name: name,
@@ -174,8 +169,7 @@ class VariableData
174169
);
175170

176171
/// Returns the value converted to the appropriate type according to [type].
177-
Object? getValue() =>
178-
switch (type) {
172+
Object? getValue() => switch (type) {
179173
VariableType.text => value.isEmpty ? null : value,
180174
VariableType.image => value.isEmpty ? null : value,
181175
VariableType.integer => num.tryParse(value).toInt(),
@@ -218,7 +212,7 @@ String? sanitizeValueForVariableType(Object? value, VariableType type) {
218212
final hexMatch = hexColorRegex.firstMatch(value.toString());
219213
if (hexMatch != null) return value.toString().toUpperCase();
220214
return null;
221-
// This could be a bit expensive. Maybe enable only when required!
215+
// This could be a bit expensive. Maybe enable only when required!
222216
case VariableType.map:
223217
if (value is Map) return jsonEncode(value);
224218
final map = value.toMap();
@@ -279,8 +273,7 @@ class CanvasVariableData extends VariableData {
279273

280274
@override
281275
Map<String, dynamic> toJson() =>
282-
_$CanvasVariableDataToJson(this)
283-
..remove('canvasId');
276+
_$CanvasVariableDataToJson(this)..remove('canvasId');
284277
}
285278

286279
/// A variable class that represents creation of a variable from given name.
@@ -371,7 +364,7 @@ class LeafAccessor extends Accessor {
371364
/// Creates a new [LeafAccessor] from an [Accessor].
372365
LeafAccessor.from(Accessor accessor)
373366
: super(
374-
name: accessor.name,
375-
type: accessor.type,
376-
getValue: accessor.getValue);
367+
name: accessor.name,
368+
type: accessor.type,
369+
getValue: accessor.getValue);
377370
}

0 commit comments

Comments
 (0)