Skip to content

Commit

Permalink
[ios_platform_images] Adopt code-excerpts (flutter#5682)
Browse files Browse the repository at this point in the history
Replaces the Dart example code with a code excerpt.

Part of flutter/flutter#102679
  • Loading branch information
stuartmorgan authored and arc-yong committed Jun 14, 2024
1 parent 2f043fa commit 9ba93b5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
3 changes: 2 additions & 1 deletion packages/ios_platform_images/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.2.3+1

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

## 0.2.3
Expand Down
21 changes: 7 additions & 14 deletions packages/ios_platform_images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ When loading images from Image.xcassets the device specific variant is chosen

### iOS->Flutter Example

``` dart
// Import package
import 'package:ios_platform_images/ios_platform_images.dart';
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Image(image: IosPlatformImages.load("flutter")),
),
//..
),
);
}
<?code-excerpt "example/lib/main.dart (Usage)"?>
```dart
// "flutter" is a resource in Assets.xcassets.
final Image xcassetImage = Image(
image: IosPlatformImages.load('flutter'),
semanticLabel: 'Flutter logo',
);
```

`IosPlatformImages.load` works similarly to [`UIImage(named:)`](https://developer.apple.com/documentation/uikit/uiimage/1624146-imagenamed).
Expand Down
13 changes: 8 additions & 5 deletions packages/ios_platform_images/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
// #docregion Usage
// "flutter" is a resource in Assets.xcassets.
final Image xcassetImage = Image(
image: IosPlatformImages.load('flutter'),
semanticLabel: 'Flutter logo',
);
// #enddocregion Usage
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
// "flutter" is a resource in Assets.xcassets.
child: Image(
image: IosPlatformImages.load('flutter'),
semanticLabel: 'Flutter logo',
),
child: xcassetImage,
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/ios_platform_images/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: ios_platform_images
description: A plugin to share images between Flutter and iOS in add-to-app setups.
repository: https://github.com/flutter/packages/tree/main/packages/ios_platform_images
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+ios_platform_images%22
version: 0.2.3
version: 0.2.3+1

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down
1 change: 0 additions & 1 deletion script/configs/temp_exclude_excerpt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- go_router_builder
- image_picker_for_web
- in_app_purchase/in_app_purchase
- ios_platform_images
- palette_generator
- pointer_interceptor
- quick_actions/quick_actions

0 comments on commit 9ba93b5

Please sign in to comment.