Skip to content

Commit aaebc6e

Browse files
authored
[rfw] Add some more documentation for RFW (#4349)
1 parent cbec816 commit aaebc6e

File tree

10 files changed

+1140
-85
lines changed

10 files changed

+1140
-85
lines changed

packages/rfw/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
## 1.0.11
2+
3+
* Adds more documentation in the README.md file!
4+
* Adds automated verification of the sample code in the README.
5+
16
## 1.0.10
27

3-
* Fixes stale ignore: prefer_const_constructors.
8+
* Fixes stale ignore: `prefer_const_constructors`.
49
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
510
* Changes package internals to avoid explicit `as Uint8List` downcast.
611

packages/rfw/README.md

Lines changed: 796 additions & 81 deletions
Large diffs are not rendered by default.

packages/rfw/example/hello/lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ void main() {
1616
runApp(const Example());
1717
}
1818

19+
// The "#docregion" comment helps us keep this code in sync with the
20+
// excerpt in the rfw package's README.md file.
21+
//
22+
// #docregion Example
1923
class Example extends StatefulWidget {
2024
const Example({super.key});
2125

@@ -54,8 +58,11 @@ class _ExampleState extends State<Example> {
5458
@override
5559
void initState() {
5660
super.initState();
61+
// Local widget library:
5762
_runtime.update(coreName, createCoreWidgets());
63+
// Remote widget library:
5864
_runtime.update(mainName, _remoteWidgets);
65+
// Configuration data:
5966
_data.update('greet', <String, Object>{'name': 'World'});
6067
}
6168

@@ -73,3 +80,4 @@ class _ExampleState extends State<Example> {
7380
);
7481
}
7582
}
83+
// #enddocregion Example

packages/rfw/example/local/lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ void main() {
1616
runApp(const Example());
1717
}
1818

19+
// The "#docregion" comment helps us keep this code in sync with the
20+
// excerpt in the rfw package's README.md file.
21+
//
22+
// #docregion Example
1923
class Example extends StatefulWidget {
2024
const Example({super.key});
2125

@@ -35,6 +39,9 @@ class _ExampleState extends State<Example> {
3539

3640
@override
3741
void reassemble() {
42+
// This function causes the Runtime to be updated any time the app is
43+
// hot reloaded, so that changes to _createLocalWidgets can be seen
44+
// during development. This function has no effect in production.
3845
super.reassemble();
3946
_update();
4047
}
@@ -87,3 +94,4 @@ class _ExampleState extends State<Example> {
8794
);
8895
}
8996
}
97+
// #enddocregion Example

packages/rfw/example/wasm/logic/calculator.rfwtxt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ widget CalculatorPad = Column(
2525
children: [
2626
Row(
2727
children: [
28+
// The "#docregion" pragma here allows us to inline this as an example
29+
// in the "rfw" package's README.md file. It is unrelated to what this
30+
// example is otherwise trying to show and can be disregarded.
31+
// #docregion button7
2832
CalculatorButton(label: "7", onPressed: event "digit" { arguments: [7] }),
33+
// #enddocregion button7
2934
CalculatorButton(label: "8", onPressed: event "digit" { arguments: [8] }),
3035
CalculatorButton(label: "9", onPressed: event "digit" { arguments: [9] }),
3136
SizedBox(width: 116.0, height: 116.0),
@@ -58,6 +63,7 @@ widget CalculatorPad = Column(
5863
],
5964
);
6065

66+
// #docregion CalculatorButton
6167
widget CalculatorButton = Padding(
6268
padding: [8.0],
6369
child: SizedBox(
@@ -69,7 +75,9 @@ widget CalculatorButton = Padding(
6975
),
7076
),
7177
);
78+
// #enddocregion CalculatorButton
7279

80+
// #docregion Button
7381
widget Button { down: false } = GestureDetector(
7482
onTap: args.onPressed,
7583
onTapDown: set state.down = true,
@@ -110,6 +118,7 @@ widget Button { down: false } = GestureDetector(
110118
),
111119
),
112120
);
121+
// #enddocregion Button
113122

114123
widget Display = Container(
115124
height: 80.0,

packages/rfw/lib/src/dart/text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ DynamicMap parseDataFile(String file) {
533533
/// event "..." { }
534534
/// ```
535535
///
536-
/// Tthe string is the name of the event, and the arguments map is the data to
536+
/// The string is the name of the event, and the arguments map is the data to
537537
/// send with the event.
538538
///
539539
/// For example, the event handler in the following sequence sends the event

packages/rfw/lib/src/flutter/core_widgets.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
537537
);
538538
},
539539

540+
// The "#docregion" pragma below makes this accessible from the README.md file.
541+
// #docregion Row
540542
'Row': (BuildContext context, DataSource source) {
541543
return Row(
542544
mainAxisAlignment: ArgumentDecoders.enumValue<MainAxisAlignment>(MainAxisAlignment.values, source, ['mainAxisAlignment']) ?? MainAxisAlignment.start,
@@ -548,6 +550,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
548550
children: source.childList(['children']),
549551
);
550552
},
553+
// #enddocregion Row
551554

552555
'SafeArea': (BuildContext context, DataSource source) {
553556
return SafeArea(

packages/rfw/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: rfw
22
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
33
repository: https://github.com/flutter/packages/tree/main/packages/rfw
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
5-
version: 1.0.10
5+
version: 1.0.11
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"

0 commit comments

Comments
 (0)