Skip to content

Commit 36e088a

Browse files
[quick_actions] Adopt code-excerpts for README (#12643)
Replaces the hand-written Dart snippets in `quick_actions`'s README with `<?code-excerpt?>` pragmas backed by `example/lib/readme_excerpts.dart`, so they're validated against compilable, analyzed source instead of free-hand text (the original used an untyped callback parameter and `print()`, which the repo's lint rules disallow). Also drops the package's `ci_config.yaml`, whose only purpose was opting it out of that validation. Follows the same pattern as #12641 ([pointer_interceptor] Adopt code-excerpts for README). Part of #102679. ## Pre-Review Checklist ## Test plan [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. **Note**: The Flutter team is currently trialing [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from `gemini-code-assist[bot]` aren't authoritative Flutter-team feedback; I'll wait for a human reviewer's guidance on which automated comments (if any) should be addressed.
1 parent 956ba9e commit 36e088a

5 files changed

Lines changed: 52 additions & 9 deletions

File tree

‎packages/quick_actions/quick_actions/CHANGELOG.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## NEXT
1+
## 1.1.1
22

3+
* Adopts `code-excerpt` for the README's Dart snippets so they are validated
4+
against compilable, analyzed source.
35
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.
46
* Updates README to reflect currently supported OS versions for the latest
57
versions of the endorsed platform implementations.

‎packages/quick_actions/quick_actions/README.md‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# quick_actions
2+
<?code-excerpt path-base="example/lib"?>
23

34
This Flutter plugin allows you to manage and interact with the application's
45
home screen quick actions.
@@ -19,22 +20,29 @@ Initialize the library early in your application's lifecycle by providing a
1920
callback, which will then be called whenever the user launches the app via a
2021
quick action.
2122

23+
<?code-excerpt "readme_excerpts.dart (Initialize)"?>
2224
```dart
23-
final QuickActions quickActions = const QuickActions();
24-
quickActions.initialize((shortcutType) {
25+
const quickActions = QuickActions();
26+
quickActions.initialize((String shortcutType) {
2527
if (shortcutType == 'action_main') {
26-
print('The user tapped on the "Main view" action.');
28+
debugPrint('The user tapped on the "Main view" action.');
2729
}
2830
// More handling code...
2931
});
3032
```
3133

3234
Finally, manage the app's quick actions, for instance:
3335

36+
<?code-excerpt "readme_excerpts.dart (SetShortcutItems)"?>
3437
```dart
35-
quickActions.setShortcutItems(<ShortcutItem>[
38+
await quickActions.setShortcutItems(<ShortcutItem>[
3639
const ShortcutItem(type: 'action_main', localizedTitle: 'Main view', icon: 'icon_main'),
37-
const ShortcutItem(type: 'action_help', localizedTitle: 'Help', localizedSubtitle: 'Tap to get help', icon: 'icon_help')
40+
const ShortcutItem(
41+
type: 'action_help',
42+
localizedTitle: 'Help',
43+
localizedSubtitle: 'Tap to get help',
44+
icon: 'icon_help',
45+
),
3846
]);
3947
```
4048

‎packages/quick_actions/quick_actions/ci_config.yaml‎

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2013 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+
import 'package:flutter/foundation.dart';
6+
import 'package:quick_actions/quick_actions.dart';
7+
8+
/// Initializes the plugin and handles quick action launches.
9+
void initializeSnippet() {
10+
// #docregion Initialize
11+
const quickActions = QuickActions();
12+
quickActions.initialize((String shortcutType) {
13+
if (shortcutType == 'action_main') {
14+
debugPrint('The user tapped on the "Main view" action.');
15+
}
16+
// More handling code...
17+
});
18+
// #enddocregion Initialize
19+
}
20+
21+
/// Sets the shortcut items shown on the device's home screen.
22+
Future<void> setShortcutItemsSnippet() async {
23+
const quickActions = QuickActions();
24+
// #docregion SetShortcutItems
25+
await quickActions.setShortcutItems(<ShortcutItem>[
26+
const ShortcutItem(type: 'action_main', localizedTitle: 'Main view', icon: 'icon_main'),
27+
const ShortcutItem(
28+
type: 'action_help',
29+
localizedTitle: 'Help',
30+
localizedSubtitle: 'Tap to get help',
31+
icon: 'icon_help',
32+
),
33+
]);
34+
// #enddocregion SetShortcutItems
35+
}

‎packages/quick_actions/quick_actions/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for creating shortcuts on home screen, also known as
33
Quick Actions on iOS and App Shortcuts on Android.
44
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+quick_actions%22
6-
version: 1.1.0
6+
version: 1.1.1
77

88
environment:
99
sdk: ^3.10.0

0 commit comments

Comments
 (0)