mirror of
https://github.com/flutter/packages.git
synced 2025-06-27 04:37:07 +08:00
[flutter_image] Adopt code excerpts in README (#5498)
Updates the README to use a compiled excerpt source for its example of using `NetworkImageWithRetry`. Part of [flutter/flutter#102679](https://github.com/flutter/flutter/issues/102679)
This commit is contained in:

committed by
GitHub

parent
7a11e2dc12
commit
44a8ce1d55
@ -2,6 +2,7 @@
|
||||
|
||||
* Fixes image asset link to use image within package.
|
||||
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
|
||||
* Updates README to improve example of using `NetworkImageWithRetry`.
|
||||
|
||||
## 4.1.9
|
||||
|
||||
|
@ -7,9 +7,10 @@ network with a retry mechanism.
|
||||
|
||||
Example:
|
||||
|
||||
<?code-excerpt "example/lib/readme_excerpts.dart (NetworkImageWithRetry)"?>
|
||||
```dart
|
||||
var avatar = new Image(
|
||||
image: new NetworkImageWithRetry('http://example.com/avatars/123.jpg'),
|
||||
const Image avatar = Image(
|
||||
image: NetworkImageWithRetry('http://example.com/avatars/123.jpg'),
|
||||
);
|
||||
```
|
||||
|
||||
|
17
packages/flutter_image/example/lib/readme_excerpts.dart
Normal file
17
packages/flutter_image/example/lib/readme_excerpts.dart
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_image/flutter_image.dart';
|
||||
|
||||
/// Demonstrates loading an image for the README.
|
||||
Image networkImageWithRetry() {
|
||||
// #docregion NetworkImageWithRetry
|
||||
const Image avatar = Image(
|
||||
image: NetworkImageWithRetry('http://example.com/avatars/123.jpg'),
|
||||
);
|
||||
// #enddocregion NetworkImageWithRetry
|
||||
|
||||
return avatar;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_image/flutter_image.dart';
|
||||
import 'package:flutter_image_example/readme_excerpts.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('networkImageWithRetry returns an Image with NetworkImageWithRetry', () {
|
||||
// Ensure that the snippet code runs successfully.
|
||||
final Image result = networkImageWithRetry();
|
||||
|
||||
// It should have a image property of the right type.
|
||||
expect(result.image, isInstanceOf<NetworkImageWithRetry>());
|
||||
// And the NetworkImageWithRetry should have a url property.
|
||||
final NetworkImageWithRetry networkImage =
|
||||
result.image as NetworkImageWithRetry;
|
||||
expect(networkImage.url, equals('http://example.com/avatars/123.jpg'));
|
||||
});
|
||||
}
|
@ -8,7 +8,6 @@
|
||||
- css_colors
|
||||
- espresso
|
||||
- extension_google_sign_in_as_googleapis_auth
|
||||
- flutter_image
|
||||
- go_router_builder
|
||||
- google_sign_in/google_sign_in
|
||||
- image_picker_for_web
|
||||
|
Reference in New Issue
Block a user