Skip to content

Commit 9dddb73

Browse files
committed
Simplified context data model.
1 parent 2ac35ba commit 9dddb73

File tree

2 files changed

+6
-46
lines changed

2 files changed

+6
-46
lines changed

packages/flutter_genui/lib/src/core/widget_utilities.dart

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:convert';
6-
75
import 'package:flutter/foundation.dart';
86
import 'package:flutter/material.dart';
97

@@ -79,34 +77,8 @@ JsonMap resolveContext(
7977
final resolved = <String, Object?>{};
8078
for (final contextEntry in contextDefinitions) {
8179
final entry = contextEntry as JsonMap;
82-
final key = entry['name']! as String;
83-
final valueDefinition = entry;
84-
85-
if (valueDefinition.containsKey('path')) {
86-
resolved[key] = dataContext.getValue(valueDefinition['path'] as String);
87-
} else if (valueDefinition.containsKey('literalString')) {
88-
resolved[key] = valueDefinition['literalString'];
89-
} else if (valueDefinition.containsKey('literalNumber')) {
90-
resolved[key] = valueDefinition['literalNumber'];
91-
} else if (valueDefinition.containsKey('literalBoolean')) {
92-
resolved[key] = valueDefinition['literalBoolean'];
93-
} else {
94-
resolved[key] = null;
95-
throw DataBindingException(
96-
'No data source found to bind context key "$key". '
97-
'Value definition supplied was: ${jsonEncode(valueDefinition)}',
98-
);
99-
}
80+
final key = entry['key']! as String;
81+
resolved[key] = dataContext.getValue(entry['path'] as String);
10082
}
10183
return resolved;
10284
}
103-
104-
class DataBindingException implements Exception {
105-
DataBindingException([this.message = '']);
106-
107-
final String message;
108-
109-
@override
110-
String toString() =>
111-
'$DataBindingException: Could not resolve data binding. $message';
112-
}

packages/flutter_genui/lib/src/model/a2ui_schemas.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,11 @@ class A2uiSchemas {
7878
'context': S.list(
7979
description:
8080
'A list of name-value pairs to be sent with the action. The '
81-
'values can bind to the data model with a path, and should bind '
82-
'to all of the related widget data for this action.',
81+
'values are bind to the data model with a path, and should bind '
82+
'to all of the related data for this action.',
8383
items: S.object(
84-
description:
85-
'A single piece of data to be sent with the action. Must include '
86-
'a name, but must also include either a path or a literal value. '
87-
'Prefer linking to a data model path if available.',
88-
properties: {
89-
'name': S.string(),
90-
'path': S.string(
91-
description: 'A relative or absolute path in the data model.',
92-
),
93-
'literalString': S.string(),
94-
'literalNumber': S.number(),
95-
'literalBoolean': S.boolean(),
96-
},
97-
required: ['name'],
84+
properties: {'key': S.string(), 'path': S.string()},
85+
required: ['key', 'path'],
9886
),
9987
),
10088
},

0 commit comments

Comments
 (0)