Skip to content

Commit ff81b82

Browse files
[camera_web] Adopt code excerpts in README (flutter#4584)
Updates the README to use a compiled excerpt source for its example of creating an `Image`. Part of flutter#102679
1 parent 4bd6c6b commit ff81b82

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

packages/camera/camera_web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.2+1
2+
3+
* Updates README to improve example of `Image` creation.
4+
15
## 0.3.2
26

37
* Changes `availableCameras` to not ask for the microphone permission.

packages/camera/camera_web/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ URL pointing to a location within the browser (blob) and can be displayed using
8080

8181
See the example below:
8282

83+
<?code-excerpt "example/lib/readme_excerpts.dart (ImageFromXFile)"?>
8384
```dart
85+
final Image image;
8486
if (kIsWeb) {
85-
Image.network(capturedImage.path);
87+
image = Image.network(capturedImage.path);
8688
} else {
87-
Image.file(File(capturedImage.path));
89+
image = Image.file(File(capturedImage.path));
8890
}
8991
```
9092

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:camera_platform_interface/camera_platform_interface.dart';
8+
import 'package:flutter/foundation.dart';
9+
import 'package:flutter/widgets.dart';
10+
11+
/// Demonstrates using an XFile result as an [Image] source, for the README.
12+
Image getImageFromResultExample(XFile capturedImage) {
13+
// #docregion ImageFromXFile
14+
final Image image;
15+
if (kIsWeb) {
16+
image = Image.network(capturedImage.path);
17+
} else {
18+
image = Image.file(File(capturedImage.path));
19+
}
20+
// #enddocregion ImageFromXFile
21+
return image;
22+
}

packages/camera/camera_web/example/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ environment:
66
flutter: ">=3.3.0"
77

88
dependencies:
9+
camera_platform_interface: ^2.1.0
10+
camera_web:
11+
path: ../
912
flutter:
1013
sdk: flutter
1114

1215
dev_dependencies:
1316
async: ^2.5.0
14-
camera_platform_interface: ^2.1.0
15-
camera_web:
16-
path: ../
1717
cross_file: ^0.3.1
1818
flutter_test:
1919
sdk: flutter

packages/camera/camera_web/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_web
22
description: A Flutter plugin for getting information about and controlling the camera on Web.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.3.2
5+
version: 0.3.2+1
66

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

script/configs/temp_exclude_excerpt.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
# TODO(stuartmorgan): Remove everything from this list. See
77
# https://github.com/flutter/flutter/issues/102679
8-
- camera_web
98
- cross_file
109
- css_colors
1110
- espresso

0 commit comments

Comments
 (0)