Skip to content

Commit bba8a70

Browse files
authored
Create Dart replicas for Flutter's notifiers. (#850)
1 parent a65c8d1 commit bba8a70

File tree

21 files changed

+881
-449
lines changed

21 files changed

+881
-449
lines changed

.github/workflows/flutter_packages.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ jobs:
169169
fi
170170
171171
- name: Check for cycles
172-
if: matrix.package.path != 'packages/ui_primitives'
173172
working-directory: ${{ matrix.package.path }}
174173
run: |
175174
dart pub global activate layerlens

packages/a2ui_core/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `a2ui_core` Changelog
2+
3+
## 0.0.1
4+
5+
- Initial version.

packages/a2ui_core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# A2UI Core
2+
3+
Core model for A2UI protocol.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2025 The Flutter Authors.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
export 'src/listenable/error_reporting.dart'
6+
show ListenableError, ListenableErrorDetails;
7+
export 'src/listenable/notifiers.dart'
8+
show ChangeNotifier, GenUiListenable, GenUiValueListenable, ValueNotifier;
9+
export 'src/listenable/primitives.dart' show VoidCallback;
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2025 The Flutter Authors.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
class ListenableErrorReporting {
6+
/// Creates an error with the given message.
7+
static Error createError(String message) =>
8+
ListenableError(ListenableErrorDetails(exception: message));
9+
10+
/// Reports an error.
11+
///
12+
/// Adds the error to [reportedErrors].
13+
///
14+
/// The list of errors should be verified and cleaned regularly
15+
/// by the framework or application.
16+
static void report(ListenableErrorDetails details) =>
17+
_reportedErrors.add(details);
18+
19+
/// Returns the list of reported errors.
20+
static Iterable<ListenableErrorDetails> get reportedErrors => _reportedErrors;
21+
static final _reportedErrors = <ListenableErrorDetails>[];
22+
23+
/// Clears the list of reported errors.
24+
static void clearReportedErrors() => _reportedErrors.clear();
25+
}
26+
27+
final class ListenableError extends Error {
28+
ListenableError(this.details);
29+
30+
final ListenableErrorDetails details;
31+
32+
@override
33+
String toString() {
34+
return details.toString();
35+
}
36+
}
37+
38+
final class ListenableErrorDetails {
39+
ListenableErrorDetails({
40+
required this.exception,
41+
this.dispatchingObject,
42+
this.stack,
43+
});
44+
45+
final Object? dispatchingObject;
46+
final Object exception;
47+
final StackTrace? stack;
48+
49+
@override
50+
String toString() {
51+
final parts = [
52+
if (dispatchingObject != null)
53+
'$dispatchingObject reported $exception'
54+
else
55+
'$exception',
56+
if (stack != null) '$stack',
57+
];
58+
return parts.join('\n');
59+
}
60+
}

0 commit comments

Comments
 (0)