Skip to content

[camera_web] Adopt code excerpts in README #4584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 4 additions & 2 deletions packages/camera/camera_web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
```

Expand Down
22 changes: 22 additions & 0 deletions packages/camera/camera_web/example/lib/readme_excerpts.dart
Original file line number Diff line number Diff line change
@@ -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 changes: 3 additions & 3 deletions packages/camera/camera_web/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion script/configs/temp_exclude_excerpt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down