[cupertino_ui] Adopt code excerpts in README (#13400)

This PR adopts the repository's code-excerpt mechanism for the documentation examples in the `cupertino_ui` package.

### Changes

- Adds `example/lib/readme_excerpts.dart` as the maintained source for the app-wide compatibility bridge, subtree compatibility bridge, and Dartdoc example snippets.
- Updates `packages/cupertino_ui/README.md` and `packages/cupertino_ui/example/README.md` to generate their Dart code examples from named source regions.
- Removes the obsolete `exempt_from_excerpts: true` configuration from `ci_config.yaml`, enabling README excerpt enforcement for this package.
- Corrects the installation command's code fence from `dart` to `sh`.
- Adds a pending changelog entry with `version: patch`, following the package's batch-release process.
- Adds smoke tests in `example/test/readme_excerpts_test.dart` to verify the app-wide and subtree compatibility bridge examples.

These changes keep the published documentation examples synchronized with maintained source code and allow the repository's excerpt validation to detect inconsistencies.

### Related issue

Part of [[flutter/flutter#102679](https://github.com/flutter/flutter/issues/102679)] - Adopt code-excerpt across all READMEs.

### Validation

Validation performed after synchronizing with the latest PR branch:

- `fvm flutter analyze` - passed with no issues.
- `fvm flutter test test/readme_excerpts_test.dart` - passed. 2 tests passed.
- `fvm flutter test` - passed. 132 tests passed, 2 skipped.
- Working tree was clean before pushing the changes.

Earlier package validation:
- Package tests: 1,959 passed, 6 skipped.
- Example tests: 130 passed, 2 skipped, before the additional smoke tests were added.
- General package validation with `--no-check-for-missing-changes` passed.
- `git diff --check` passed.

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [[Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code)]. Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find the comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^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.
diff --git a/packages/cupertino_ui/README.md b/packages/cupertino_ui/README.md
index 4ab0f98..20d6fe8 100644
--- a/packages/cupertino_ui/README.md
+++ b/packages/cupertino_ui/README.md
@@ -1,5 +1,7 @@
 # cupertino_ui
 
+<?code-excerpt path-base="example/lib"?>
+
 The official Flutter Cupertino library, implementing Apple's [Human Interface
 Guidelines](https://developer.apple.com/design/human-interface-guidelines/) for
 Flutter applications.
@@ -16,7 +18,7 @@
 
 Install the package with the following command:
 
-```dart
+```sh
 flutter pub add cupertino_ui
 ```
 
@@ -62,6 +64,7 @@
 
 Wrap your app using `CupertinoApp.builder`:
 
+<?code-excerpt "readme_excerpts.dart (AppWideUsage)"?>
 ```dart
 import 'package:cupertino_ui/cupertino_ui.dart';
 
@@ -86,14 +89,13 @@
 
 You can also wrap individual subtrees that contain legacy package widgets:
 
+<?code-excerpt "readme_excerpts.dart (SubtreeUsage)"?>
 ```dart
 CupertinoPageScaffold(
   navigationBar: const CupertinoNavigationBar(
     middle: Text('Modern Screen'),
   ),
-  child: CupertinoUiCompatibilityBridge(
-    child: LegacyPackageWidget(),
-  ),
+  child: CupertinoUiCompatibilityBridge(child: const LegacyPackageWidget()),
 )
 ```
 
diff --git a/packages/cupertino_ui/ci_config.yaml b/packages/cupertino_ui/ci_config.yaml
index df2799b..dcee40a 100644
--- a/packages/cupertino_ui/ci_config.yaml
+++ b/packages/cupertino_ui/ci_config.yaml
@@ -1,5 +1,3 @@
-# TODO(stuartmorgan): Remove this; see https://github.com/flutter/flutter/issues/102679
-exempt_from_excerpts: true
 release:
   batch: true
 
diff --git a/packages/cupertino_ui/example/README.md b/packages/cupertino_ui/example/README.md
index c80ea39..d45bbe2 100644
--- a/packages/cupertino_ui/example/README.md
+++ b/packages/cupertino_ui/example/README.md
@@ -53,6 +53,7 @@
 the symbol you would like to attach it to. Here's what it might look like if you
 wanted to add a new example to the `CupertinoActivityIndicator` class:
 
+<?code-excerpt "lib/readme_excerpts.dart (DartdocComment)"?>
 ```dart
 /// {@example /example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
 /// Write a description of the example here. This description will appear in the
diff --git a/packages/cupertino_ui/example/lib/readme_excerpts.dart b/packages/cupertino_ui/example/lib/readme_excerpts.dart
new file mode 100644
index 0000000..5664464
--- /dev/null
+++ b/packages/cupertino_ui/example/lib/readme_excerpts.dart
@@ -0,0 +1,73 @@
+// Copyright 2013 The Flutter Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// ignore_for_file: deprecated_member_use
+
+// #docregion AppWideUsage
+import 'package:cupertino_ui/cupertino_ui.dart';
+
+void main() {
+  runApp(const MyApp());
+}
+
+class MyApp extends StatelessWidget {
+  const MyApp({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return CupertinoApp(
+      builder: (BuildContext context, Widget? child) {
+        return CupertinoUiCompatibilityBridge(child: child!);
+      },
+      home: const HomeScreen(),
+    );
+  }
+}
+// #enddocregion AppWideUsage
+
+class HomeScreen extends StatelessWidget {
+  const HomeScreen({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return const CupertinoPageScaffold(child: Center(child: Text('Home')));
+  }
+}
+
+class SubtreeExample extends StatelessWidget {
+  const SubtreeExample({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return
+    // #docregion SubtreeUsage
+    CupertinoPageScaffold(
+      navigationBar: const CupertinoNavigationBar(
+        middle: Text('Modern Screen'),
+      ),
+      child: CupertinoUiCompatibilityBridge(child: const LegacyPackageWidget()),
+    )
+    // #enddocregion SubtreeUsage
+    ;
+  }
+}
+
+class LegacyPackageWidget extends StatelessWidget {
+  const LegacyPackageWidget({super.key});
+
+  @override
+  Widget build(BuildContext context) {
+    return const Text('Legacy package widget');
+  }
+}
+
+/// A Dartdoc comment template shown in `example/README.md`.
+const String dartdocCommentExample = r'''
+// #docregion DartdocComment
+/// {@example /example/lib/activity_indicator/cupertino_activity_indicator.0.dart}
+/// Write a description of the example here. This description will appear in the
+/// API web documentation to introduce the example.
+/// {@end-example}
+// #enddocregion DartdocComment
+''';
diff --git a/packages/cupertino_ui/example/test/readme_excerpts_test.dart b/packages/cupertino_ui/example/test/readme_excerpts_test.dart
new file mode 100644
index 0000000..a44bd06
--- /dev/null
+++ b/packages/cupertino_ui/example/test/readme_excerpts_test.dart
@@ -0,0 +1,58 @@
+// Copyright 2013 The Flutter Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// The README snippets intentionally demonstrate the deprecated migration
+// utility.
+// ignore_for_file: deprecated_member_use
+
+import 'package:cupertino_ui/cupertino_ui.dart';
+import 'package:cupertino_ui_examples/readme_excerpts.dart'
+    show LegacyPackageWidget, MyApp, SubtreeExample;
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+  testWidgets('AppWideUsage wraps the whole app in the bridge', (
+    WidgetTester tester,
+  ) async {
+    await tester.pumpWidget(const MyApp());
+
+    expect(find.byType(CupertinoUiCompatibilityBridge), findsOneWidget);
+    expect(
+      find.descendant(
+        of: find.byType(CupertinoUiCompatibilityBridge),
+        matching: find.text('Home'),
+      ),
+      findsOneWidget,
+    );
+    expect(tester.takeException(), isNull);
+  });
+
+  testWidgets('SubtreeUsage wraps only the legacy subtree in the bridge', (
+    WidgetTester tester,
+  ) async {
+    await tester.pumpWidget(const CupertinoApp(home: SubtreeExample()));
+
+    expect(find.text('Modern Screen'), findsOneWidget);
+    expect(find.byType(CupertinoUiCompatibilityBridge), findsOneWidget);
+    expect(
+      find.descendant(
+        of: find.byType(CupertinoUiCompatibilityBridge),
+        matching: find.byType(LegacyPackageWidget),
+      ),
+      findsOneWidget,
+    );
+
+    // The navigation bar is outside the bridge.
+    expect(
+      find.descendant(
+        of: find.byType(CupertinoUiCompatibilityBridge),
+        matching: find.text('Modern Screen'),
+      ),
+      findsNothing,
+    );
+
+    expect(find.text('Legacy package widget'), findsOneWidget);
+    expect(tester.takeException(), isNull);
+  });
+}
diff --git a/packages/cupertino_ui/pending_changelogs/readme_code_excerpts.yaml b/packages/cupertino_ui/pending_changelogs/readme_code_excerpts.yaml
new file mode 100644
index 0000000..790b52a
--- /dev/null
+++ b/packages/cupertino_ui/pending_changelogs/readme_code_excerpts.yaml
@@ -0,0 +1,3 @@
+changelog: |
+  - Updates the README examples to use generated code excerpts.
+version: patch