mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 14:47:22 +08:00
[camera_web] Adopt code excerpts in README (#4584)
Updates the README to use a compiled excerpt source for its example of creating an `Image`. Part of https://github.com/flutter/flutter/issues/102679
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 0.3.2+1
|
||||||
|
|
||||||
|
* Updates README to improve example of `Image` creation.
|
||||||
|
|
||||||
## 0.3.2
|
## 0.3.2
|
||||||
|
|
||||||
* Changes `availableCameras` to not ask for the microphone permission.
|
* Changes `availableCameras` to not ask for the microphone permission.
|
||||||
|
@ -80,11 +80,13 @@ URL pointing to a location within the browser (blob) and can be displayed using
|
|||||||
|
|
||||||
See the example below:
|
See the example below:
|
||||||
|
|
||||||
|
<?code-excerpt "example/lib/readme_excerpts.dart (ImageFromXFile)"?>
|
||||||
```dart
|
```dart
|
||||||
|
final Image image;
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
Image.network(capturedImage.path);
|
image = Image.network(capturedImage.path);
|
||||||
} else {
|
} else {
|
||||||
Image.file(File(capturedImage.path));
|
image = Image.file(File(capturedImage.path));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
22
packages/camera/camera_web/example/lib/readme_excerpts.dart
Normal file
22
packages/camera/camera_web/example/lib/readme_excerpts.dart
Normal file
@ -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 'dart:io';
|
||||||
|
|
||||||
|
import 'package:camera_platform_interface/camera_platform_interface.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Demonstrates using an XFile result as an [Image] source, for the README.
|
||||||
|
Image getImageFromResultExample(XFile capturedImage) {
|
||||||
|
// #docregion ImageFromXFile
|
||||||
|
final Image image;
|
||||||
|
if (kIsWeb) {
|
||||||
|
image = Image.network(capturedImage.path);
|
||||||
|
} else {
|
||||||
|
image = Image.file(File(capturedImage.path));
|
||||||
|
}
|
||||||
|
// #enddocregion ImageFromXFile
|
||||||
|
return image;
|
||||||
|
}
|
@ -6,14 +6,14 @@ environment:
|
|||||||
flutter: ">=3.3.0"
|
flutter: ">=3.3.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
camera_platform_interface: ^2.1.0
|
||||||
|
camera_web:
|
||||||
|
path: ../
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
async: ^2.5.0
|
async: ^2.5.0
|
||||||
camera_platform_interface: ^2.1.0
|
|
||||||
camera_web:
|
|
||||||
path: ../
|
|
||||||
cross_file: ^0.3.1
|
cross_file: ^0.3.1
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
@ -2,7 +2,7 @@ name: camera_web
|
|||||||
description: A Flutter plugin for getting information about and controlling the camera on Web.
|
description: A Flutter plugin for getting information about and controlling the camera on Web.
|
||||||
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
|
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
|
||||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
|
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
|
||||||
version: 0.3.2
|
version: 0.3.2+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.18.0 <4.0.0"
|
sdk: ">=2.18.0 <4.0.0"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
# TODO(stuartmorgan): Remove everything from this list. See
|
# TODO(stuartmorgan): Remove everything from this list. See
|
||||||
# https://github.com/flutter/flutter/issues/102679
|
# https://github.com/flutter/flutter/issues/102679
|
||||||
- camera_web
|
|
||||||
- cross_file
|
- cross_file
|
||||||
- css_colors
|
- css_colors
|
||||||
- espresso
|
- espresso
|
||||||
|
Reference in New Issue
Block a user