Skip to content

Commit d30bdd9

Browse files
[ios_platform_images] Adopt code-excerpts (#5682)
Replaces the Dart example code with a code excerpt. Part of flutter/flutter#102679
1 parent 05c88b3 commit d30bdd9

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

packages/ios_platform_images/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.2.3+1
22

3+
* Improves example code in README.
34
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
45

56
## 0.2.3

packages/ios_platform_images/README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@ When loading images from Image.xcassets the device specific variant is chosen
1616

1717
### iOS->Flutter Example
1818

19-
``` dart
20-
// Import package
21-
import 'package:ios_platform_images/ios_platform_images.dart';
22-
23-
Widget build(BuildContext context) {
24-
return MaterialApp(
25-
home: Scaffold(
26-
body: Center(
27-
child: Image(image: IosPlatformImages.load("flutter")),
28-
),
29-
//..
30-
),
31-
);
32-
}
19+
<?code-excerpt "example/lib/main.dart (Usage)"?>
20+
```dart
21+
// "flutter" is a resource in Assets.xcassets.
22+
final Image xcassetImage = Image(
23+
image: IosPlatformImages.load('flutter'),
24+
semanticLabel: 'Flutter logo',
25+
);
3326
```
3427

3528
`IosPlatformImages.load` works similarly to [`UIImage(named:)`](https://developer.apple.com/documentation/uikit/uiimage/1624146-imagenamed).

packages/ios_platform_images/example/lib/main.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ class _MyAppState extends State<MyApp> {
2828

2929
@override
3030
Widget build(BuildContext context) {
31+
// #docregion Usage
32+
// "flutter" is a resource in Assets.xcassets.
33+
final Image xcassetImage = Image(
34+
image: IosPlatformImages.load('flutter'),
35+
semanticLabel: 'Flutter logo',
36+
);
37+
// #enddocregion Usage
3138
return MaterialApp(
3239
home: Scaffold(
3340
appBar: AppBar(
3441
title: const Text('Plugin example app'),
3542
),
3643
body: Center(
37-
// "flutter" is a resource in Assets.xcassets.
38-
child: Image(
39-
image: IosPlatformImages.load('flutter'),
40-
semanticLabel: 'Flutter logo',
41-
),
44+
child: xcassetImage,
4245
),
4346
),
4447
);

packages/ios_platform_images/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: ios_platform_images
22
description: A plugin to share images between Flutter and iOS in add-to-app setups.
33
repository: https://github.com/flutter/packages/tree/main/packages/ios_platform_images
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+ios_platform_images%22
5-
version: 0.2.3
5+
version: 0.2.3+1
66

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

script/configs/temp_exclude_excerpt.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
- go_router_builder
1111
- image_picker_for_web
1212
- in_app_purchase/in_app_purchase
13-
- ios_platform_images
1413
- palette_generator
1514
- pointer_interceptor
1615
- quick_actions/quick_actions

0 commit comments

Comments
 (0)