Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit d5e2767

Browse files
committed
Applied PR feedback.
1 parent 0deefd1 commit d5e2767

File tree

10 files changed

+74
-51
lines changed

10 files changed

+74
-51
lines changed

packages/image_picker/image_picker_windows/README.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,4 @@ The argument `maxDuration` is not supported on Windows.
1313
### Import the package
1414

1515
This package is not yet [endorsed](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin), which means you need to add
16-
not only the `image_picker`, as well as the `image_picker_windows`.
17-
18-
### Use the plugin
19-
20-
You should be able to use `package:image_picker` _almost_ as normal, since this package is not fully featured yet.
21-
22-
If you want to use the path directly, your code would need look like this:
23-
24-
```dart
25-
...
26-
Image.file(File(pickedFile.path));
27-
...
28-
```
29-
30-
Or, using bytes:
31-
32-
```dart
33-
...
34-
Image.memory(await pickedFile.readAsBytes())
35-
...
36-
```
16+
not only the `image_picker`, as well as the `image_picker_windows`.

packages/image_picker/image_picker_windows/example/lib/main.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'dart:io';
1010
import 'package:flutter/foundation.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
13-
import 'package:image_picker_windows/image_picker_windows.dart';
1413
import 'package:video_player/video_player.dart';
1514

1615
void main() {
@@ -50,7 +49,7 @@ class _MyHomePageState extends State<MyHomePage> {
5049
VideoPlayerController? _toBeDisposed;
5150
String? _retrieveDataError;
5251

53-
final ImagePickerPlatform _picker = ImagePickerWindows();
52+
final ImagePickerPlatform _picker = ImagePickerPlatform.instance;
5453
final TextEditingController maxWidthController = TextEditingController();
5554
final TextEditingController maxHeightController = TextEditingController();
5655
final TextEditingController qualityController = TextEditingController();

packages/image_picker/image_picker_windows/example/windows/runner/flutter_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#include "flutter_window.h"
26

37
#include <optional>

packages/image_picker/image_picker_windows/example/windows/runner/flutter_window.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#ifndef RUNNER_FLUTTER_WINDOW_H_
26
#define RUNNER_FLUTTER_WINDOW_H_
37

packages/image_picker/image_picker_windows/example/windows/runner/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#include <flutter/dart_project.h>
26
#include <flutter/flutter_view_controller.h>
37
#include <windows.h>

packages/image_picker/image_picker_windows/example/windows/runner/utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#include "utils.h"
26

37
#include <flutter_windows.h>

packages/image_picker/image_picker_windows/example/windows/runner/utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#ifndef RUNNER_UTILS_H_
26
#define RUNNER_UTILS_H_
37

packages/image_picker/image_picker_windows/example/windows/runner/win32_window.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#include "win32_window.h"
26

37
#include <flutter_windows.h>

packages/image_picker/image_picker_windows/example/windows/runner/win32_window.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
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+
15
#ifndef RUNNER_WIN32_WINDOW_H_
26
#define RUNNER_WIN32_WINDOW_H_
37

packages/image_picker/image_picker_windows/lib/image_picker_windows.dart

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,48 @@
55
import 'dart:async';
66

77
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
8+
import 'package:file_selector_windows/file_selector_windows.dart';
89
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
910

11+
const List<String> _imageFormats = <String>[
12+
'jpg',
13+
'jpeg',
14+
'png',
15+
'bmp',
16+
'webp',
17+
'gif',
18+
'tif',
19+
'tiff',
20+
'apng'
21+
];
22+
const List<String> _videoFormats = <String>[
23+
'mov',
24+
'wmv',
25+
'mkv',
26+
'mp4',
27+
'webm',
28+
'avi',
29+
'mpeg',
30+
'mpg'
31+
];
32+
1033
/// The Windows implementation of [ImagePickerPlatform].
1134
///
12-
/// This class implements the `package:image_picker` functionality for Windows.
35+
/// This class implements the `package:image_picker` functionality for
36+
/// Windows.
1337
class ImagePickerWindows extends ImagePickerPlatform {
1438
/// Constructs a ImagePickerWindows.
1539
ImagePickerWindows();
1640

17-
final List<String> _imageFormats = <String>[
18-
'jpg',
19-
'jpeg',
20-
'png',
21-
'bmp',
22-
'webp',
23-
'gif',
24-
'tif',
25-
'tiff',
26-
'apng'
27-
];
28-
final List<String> _videoFormats = <String>[
29-
'mov',
30-
'wmv',
31-
'mkv',
32-
'mp4',
33-
'webm',
34-
'avi',
35-
'mpeg',
36-
'mpg'
37-
];
38-
3941
/// Registers this class as the default instance of [ImagePickerPlatform].
4042
static void registerWith() {
4143
ImagePickerPlatform.instance = ImagePickerWindows();
44+
FileSelectorWindows.registerWith();
4245
}
4346

44-
// Note that the `maxWidth`, `maxHeight` and `imageQuality` arguments are not supported on the Windows. If any of these arguments is supplied, it'll be silently ignored by the Windows version of the plugin.
47+
// Note that the `maxWidth`, `maxHeight` and `imageQuality` arguments are
48+
// not supported on the Windows. If any of these arguments is supplied,
49+
// it'll be silently ignored by the Windows version of the plugin.
4550
@override
4651
Future<PickedFile?> pickImage({
4752
required ImageSource source,
@@ -62,7 +67,10 @@ class ImagePickerWindows extends ImagePickerPlatform {
6267
return null;
6368
}
6469

65-
// Note that the `source`, `preferredCameraDevice`, and `maxDuration` arguments are not supported on Windows. If any of these arguments is supplied, it'll be silently ignored by the Windows version of the plugin.
70+
// Note that the `source`, `preferredCameraDevice`, and `maxDuration`
71+
// arguments are not supported on Windows. If any of these arguments is
72+
// supplied, it'll be silently ignored by the Windows version of the
73+
// plugin.
6674
@override
6775
Future<PickedFile?> pickVideo({
6876
required ImageSource source,
@@ -79,7 +87,10 @@ class ImagePickerWindows extends ImagePickerPlatform {
7987
return null;
8088
}
8189

82-
// Note that the `source`, `maxWidth`, `maxHeight`, `imageQuality`, and `preferredCameraDevice` arguments are not supported on Windows. If any of these arguments is supplied, it'll be silently ignored by the Windows version of the plugin.
90+
// Note that the `source`, `maxWidth`, `maxHeight`, `imageQuality`, and
91+
// `preferredCameraDevice` arguments are not supported on Windows. If
92+
// any of these arguments is supplied, it'll be silently ignored by the
93+
// Windows version of the plugin.
8394
@override
8495
Future<XFile?> getImage({
8596
required ImageSource source,
@@ -95,7 +106,10 @@ class ImagePickerWindows extends ImagePickerPlatform {
95106
return file;
96107
}
97108

98-
// Note that the `source`, `preferredCameraDevice`, and `maxDuration` arguments are not supported on Windows. If any of these arguments is supplied, it'll be silently ignored by the Windows version of the plugin.
109+
// Note that the `source`, `preferredCameraDevice`, and `maxDuration`
110+
// arguments are not supported on Windows. If any of these arguments
111+
// is supplied, it'll be silently ignored by the Windows version of
112+
// the plugin.
99113
@override
100114
Future<XFile?> getVideo({
101115
required ImageSource source,
@@ -109,7 +123,9 @@ class ImagePickerWindows extends ImagePickerPlatform {
109123
return file;
110124
}
111125

112-
// Note that the `maxWidth`, `maxHeight`, and `imageQuality` arguments are not supported on Windows. If any of these arguments is supplied, it'll be silently ignored by the Windows version of the plugin.
126+
// Note that the `maxWidth`, `maxHeight`, and `imageQuality` arguments are
127+
// not supported on Windows. If any of these arguments is supplied, it'll
128+
// be silently ignored by the Windows version of the plugin.
113129
@override
114130
Future<List<XFile>> getMultiImage({
115131
double? maxWidth,

0 commit comments

Comments
 (0)