mirror of
https://github.com/flutter/packages.git
synced 2025-06-26 03:03:23 +08:00
[ios_platform_images] Adopt code-excerpts (#5682)
Replaces the Dart example code with a code excerpt. Part of https://github.com/flutter/flutter/issues/102679
This commit is contained in:
@ -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
|
||||
|
@ -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).
|
||||
|
@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user