Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios_platform_images] Adopt code-excerpts #5682

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should rename the asset rather than explain the name with a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would we name it that wouldn't require an explanation of where the asset lives?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"asset"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or something more descriptive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of Flutter code, an asset is usually a Flutter asset, which is a similar concept but in Flutter-land (specifically, in pubspec.yaml) rather than Xcode-project-land; that's why there's a comment explaining it precisely. I guess we could name it 'assetFromAssets.xcassets', but I think that's harder to read than the comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever you think is best, that's why it's optional :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't come up with anything that I find clearer than the comment, so I'll land as-is.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

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