mirror of
https://github.com/flutter/packages.git
synced 2025-06-29 22:33:11 +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
|
||||
|
||||
* 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:
|
||||
|
||||
<?code-excerpt "example/lib/readme_excerpts.dart (ImageFromXFile)"?>
|
||||
```dart
|
||||
final Image image;
|
||||
if (kIsWeb) {
|
||||
Image.network(capturedImage.path);
|
||||
image = Image.network(capturedImage.path);
|
||||
} 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"
|
||||
|
||||
dependencies:
|
||||
camera_platform_interface: ^2.1.0
|
||||
camera_web:
|
||||
path: ../
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
async: ^2.5.0
|
||||
camera_platform_interface: ^2.1.0
|
||||
camera_web:
|
||||
path: ../
|
||||
cross_file: ^0.3.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
@ -2,7 +2,7 @@ name: camera_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
|
||||
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:
|
||||
sdk: ">=2.18.0 <4.0.0"
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
# TODO(stuartmorgan): Remove everything from this list. See
|
||||
# https://github.com/flutter/flutter/issues/102679
|
||||
- camera_web
|
||||
- cross_file
|
||||
- css_colors
|
||||
- espresso
|
||||
|
Reference in New Issue
Block a user