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

[file_selector] Use const instead of final for XTypeGroup. #6542

Merged
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
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.9.2+1

* Changes XTypeGroup initialization from final to const.
* Updates minimum Flutter version to 2.10.

## 0.9.2
Expand Down
6 changes: 3 additions & 3 deletions packages/file_selector/file_selector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Please also take a look at our [example][example] app.
#### Open a single file
<?code-excerpt "open_image_page.dart (SingleOpen)"?>
``` dart
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'images',
extensions: <String>['jpg', 'png'],
);
Expand All @@ -45,11 +45,11 @@ final XFile? file =
#### Open multiple files at once
<?code-excerpt "open_multiple_images_page.dart (MultiOpen)"?>
``` dart
final XTypeGroup jpgsTypeGroup = XTypeGroup(
const XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: <String>['jpg', 'jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
const XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: <String>['png'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'dart:io';

import 'package:file_selector/file_selector.dart';
Expand All @@ -18,7 +15,7 @@ class OpenImagePage extends StatelessWidget {

Future<void> _openImageFile(BuildContext context) async {
// #docregion SingleOpen
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'images',
extensions: <String>['jpg', 'png'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables

import 'dart:io';

import 'package:file_selector/file_selector.dart';
Expand All @@ -18,11 +15,11 @@ class OpenMultipleImagesPage extends StatelessWidget {

Future<void> _openImageFile(BuildContext context) async {
// #docregion MultiOpen
final XTypeGroup jpgsTypeGroup = XTypeGroup(
const XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: <String>['jpg', 'jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
const XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: <String>['png'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ class OpenTextPage extends StatelessWidget {
const OpenTextPage({Key? key}) : super(key: key);

Future<void> _openTextFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'text',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['txt', 'json'],
);
// This demonstrates using an initial directory for the prompt, which should
Expand Down
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for opening and saving files, or selecting
directories, using native file selection UI.
repository: https://github.com/flutter/plugins/tree/main/packages/file_selector/file_selector
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.9.2
version: 0.9.2+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -27,7 +27,7 @@ dependencies:
file_selector_ios: ^0.5.0
file_selector_linux: ^0.9.0
file_selector_macos: ^0.9.0
file_selector_platform_interface: ^2.0.0
file_selector_platform_interface: ^2.2.0
file_selector_web: ^0.9.0
file_selector_windows: ^0.9.0
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'package:file_selector/file_selector.dart';
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
import 'package:flutter_test/flutter_test.dart';
Expand All @@ -15,15 +12,11 @@ void main() {
const String initialDirectory = '/home/flutteruser';
const String confirmButtonText = 'Use this profile picture';
const String suggestedName = 'suggested_name';
final List<XTypeGroup> acceptedTypeGroups = <XTypeGroup>[
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
const List<XTypeGroup> acceptedTypeGroups = <XTypeGroup>[
XTypeGroup(label: 'documents', mimeTypes: <String>[
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessing',
]),
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
XTypeGroup(label: 'images', extensions: <String>[
'jpg',
'png',
Expand Down
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.5.0+2

* Changes XTypeGroup initialization from final to const.
* Updates minimum Flutter version to 2.10.

## 0.5.0+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@ class OpenImagePage extends StatelessWidget {
const OpenImagePage({Key? key}) : super(key: key);

Future<void> _openImageFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'images',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['jpg', 'png'],
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
macUTIs: <String>['public.image'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'dart:io';

import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
Expand All @@ -18,16 +15,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
const OpenMultipleImagesPage({Key? key}) : super(key: key);

Future<void> _openImageFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup jpgsTypeGroup = XTypeGroup(
const XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: <String>['jpg', 'jpeg'],
macUTIs: <String>['public.jpeg'],
);
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup pngTypeGroup = XTypeGroup(
const XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: <String>['png'],
macUTIs: <String>['public.png'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,9 @@ class OpenTextPage extends StatelessWidget {
const OpenTextPage({Key? key}) : super(key: key);

Future<void> _openTextFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'text',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['txt', 'json'],
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
macUTIs: <String>['public.text'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
# The example app is bundled with the plugin so we use a path dependency on
# the parent directory to use the current plugin's version.
path: ..
file_selector_platform_interface: ^2.0.0
file_selector_platform_interface: ^2.2.0
flutter:
sdk: flutter

Expand Down
4 changes: 2 additions & 2 deletions packages/file_selector/file_selector_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_selector_ios
description: iOS implementation of the file_selector plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/file_selector/file_selector_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.5.0+1
version: 0.5.0+2

environment:
sdk: ">=2.14.4 <3.0.0"
Expand All @@ -17,7 +17,7 @@ flutter:
pluginClass: FFSFileSelectorPlugin

dependencies:
file_selector_platform_interface: ^2.1.0
file_selector_platform_interface: ^2.2.0
flutter:
sdk: flutter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore_for_file: prefer_const_literals_to_create_immutables

import 'package:file_selector_ios/file_selector_ios.dart';
import 'package:file_selector_ios/src/messages.g.dart';
import 'package:file_selector_platform_interface/file_selector_platform_interface.dart';
Expand Down Expand Up @@ -39,18 +36,14 @@ void main() {
});

test('passes the accepted type groups correctly', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
);

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup groupTwo = XTypeGroup(
const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
Expand All @@ -69,9 +62,7 @@ void main() {
expect(config.allowMultiSelection, isFalse);
});
test('throws for a type group that does not support iOS', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'images',
webWildCards: <String>['images/*'],
);
Expand All @@ -82,9 +73,7 @@ void main() {
});

test('allows a wildcard group', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'text',
);

Expand All @@ -99,18 +88,14 @@ void main() {
});

test('passes the accepted type groups correctly', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'text',
extensions: <String>['txt'],
mimeTypes: <String>['text/plain'],
macUTIs: <String>['public.text'],
);

// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup groupTwo = XTypeGroup(
const XTypeGroup groupTwo = XTypeGroup(
label: 'image',
extensions: <String>['jpg'],
mimeTypes: <String>['image/jpg'],
Expand All @@ -129,9 +114,7 @@ void main() {
expect(config.allowMultiSelection, isTrue);
});
test('throws for a type group that does not support iOS', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'images',
webWildCards: <String>['images/*'],
);
Expand All @@ -142,9 +125,7 @@ void main() {
});

test('allows a wildcard group', () async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup group = XTypeGroup(
const XTypeGroup group = XTypeGroup(
label: 'text',
);

Expand Down
3 changes: 2 additions & 1 deletion packages/file_selector/file_selector_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.9.0+1

* Changes XTypeGroup initialization from final to const.
* Updates minimum Flutter version to 2.10.

## 0.9.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ class OpenImagePage extends StatelessWidget {
const OpenImagePage({Key? key}) : super(key: key);

Future<void> _openImageFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'images',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['jpg', 'png'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,12 @@ class OpenMultipleImagesPage extends StatelessWidget {
const OpenMultipleImagesPage({Key? key}) : super(key: key);

Future<void> _openImageFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup jpgsTypeGroup = XTypeGroup(
const XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['jpg', 'jpeg'],
);
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup pngTypeGroup = XTypeGroup(
const XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['png'],
);
final List<XFile> files = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ class OpenTextPage extends StatelessWidget {
const OpenTextPage({Key? key}) : super(key: key);

Future<void> _openTextFile(BuildContext context) async {
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_constructors
final XTypeGroup typeGroup = XTypeGroup(
const XTypeGroup typeGroup = XTypeGroup(
label: 'text',
// TODO(stuartmorgan): https://github.com/flutter/flutter/issues/111906
// ignore: prefer_const_literals_to_create_immutables
extensions: <String>['txt', 'json'],
);
final XFile? file = await FileSelectorPlatform.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
dependencies:
file_selector_linux:
path: ../
file_selector_platform_interface: ^2.0.0
file_selector_platform_interface: ^2.2.0
flutter:
sdk: flutter

Expand Down
Loading