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

[file_selector] Remove custom analysis options #4382

Merged
merged 4 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion packages/file_selector/analysis_options.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import 'package:flutter/material.dart';

/// Screen that shows an example of getDirectoryPath
class GetDirectoryPage extends StatelessWidget {
void _getDirectoryPath(BuildContext context) async {
final String confirmButtonText = 'Choose';
Future<void> _getDirectoryPath(BuildContext context) async {
const String confirmButtonText = 'Choose';
final String? directoryPath = await getDirectoryPath(
confirmButtonText: confirmButtonText,
);
if (directoryPath == null) {
// Operation was canceled by the user.
return;
}
await showDialog(
await showDialog<void>(
context: context,
builder: (context) => TextDisplay(directoryPath),
builder: (BuildContext context) => TextDisplay(directoryPath),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Open a text file"),
title: const Text('Open a text file'),
),
body: Center(
child: Column(
Expand All @@ -37,7 +37,7 @@ class GetDirectoryPage extends StatelessWidget {
primary: Colors.blue,
onPrimary: Colors.white,
),
child: Text('Press to ask user to choose a directory'),
child: const Text('Press to ask user to choose a directory'),
onPressed: () => _getDirectoryPath(context),
),
],
Expand All @@ -49,22 +49,22 @@ class GetDirectoryPage extends StatelessWidget {

/// Widget that displays a text file in a dialog
class TextDisplay extends StatelessWidget {
/// Default Constructor
const TextDisplay(this.directoryPath);

/// Directory path
final String directoryPath;

/// Default Constructor
TextDisplay(this.directoryPath);

@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('Selected Directory'),
title: const Text('Selected Directory'),
content: Scrollbar(
child: SingleChildScrollView(
child: Text(directoryPath),
),
),
actions: [
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () => Navigator.pop(context),
Expand Down
20 changes: 10 additions & 10 deletions packages/file_selector/file_selector/example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ class HomePage extends StatelessWidget {
);
return Scaffold(
appBar: AppBar(
title: Text('File Selector Demo Home Page'),
title: const Text('File Selector Demo Home Page'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
style: style,
child: Text('Open a text file'),
child: const Text('Open a text file'),
onPressed: () => Navigator.pushNamed(context, '/open/text'),
),
SizedBox(height: 10),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: Text('Open an image'),
child: const Text('Open an image'),
onPressed: () => Navigator.pushNamed(context, '/open/image'),
),
SizedBox(height: 10),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: Text('Open multiple images'),
child: const Text('Open multiple images'),
onPressed: () => Navigator.pushNamed(context, '/open/images'),
),
SizedBox(height: 10),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: Text('Save a file'),
child: const Text('Save a file'),
onPressed: () => Navigator.pushNamed(context, '/save/text'),
),
SizedBox(height: 10),
const SizedBox(height: 10),
ElevatedButton(
style: style,
child: Text('Open a get directory dialog'),
child: const Text('Open a get directory dialog'),
onPressed: () => Navigator.pushNamed(context, '/directory'),
),
],
Expand Down
18 changes: 9 additions & 9 deletions packages/file_selector/file_selector/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:example/home_page.dart';
import 'package:example/get_directory_page.dart';
import 'package:example/open_text_page.dart';
import 'package:example/home_page.dart';
import 'package:example/open_image_page.dart';
import 'package:example/open_multiple_images_page.dart';
import 'package:example/open_text_page.dart';
import 'package:example/save_text_page.dart';
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
Expand All @@ -25,12 +25,12 @@ class MyApp extends StatelessWidget {
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: HomePage(),
routes: {
'/open/image': (context) => OpenImagePage(),
'/open/images': (context) => OpenMultipleImagesPage(),
'/open/text': (context) => OpenTextPage(),
'/save/text': (context) => SaveTextPage(),
'/directory': (context) => GetDirectoryPage(),
routes: <String, WidgetBuilder>{
'/open/image': (BuildContext context) => OpenImagePage(),
'/open/images': (BuildContext context) => OpenMultipleImagesPage(),
'/open/text': (BuildContext context) => OpenTextPage(),
'/save/text': (BuildContext context) => SaveTextPage(),
'/directory': (BuildContext context) => GetDirectoryPage(),
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
// found in the LICENSE file.

import 'dart:io';
import 'package:flutter/foundation.dart';

import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

/// Screen that shows an example of openFiles
class OpenImagePage extends StatelessWidget {
void _openImageFile(BuildContext context) async {
Future<void> _openImageFile(BuildContext context) async {
final XTypeGroup typeGroup = XTypeGroup(
label: 'images',
extensions: ['jpg', 'png'],
extensions: <String>['jpg', 'png'],
);
final List<XFile> files = await openFiles(acceptedTypeGroups: [typeGroup]);
final List<XFile> files =
await openFiles(acceptedTypeGroups: <XTypeGroup>[typeGroup]);
if (files.isEmpty) {
// Operation was canceled by the user.
return;
Expand All @@ -23,17 +25,17 @@ class OpenImagePage extends StatelessWidget {
final String fileName = file.name;
final String filePath = file.path;

await showDialog(
await showDialog<void>(
context: context,
builder: (context) => ImageDisplay(fileName, filePath),
builder: (BuildContext context) => ImageDisplay(fileName, filePath),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Open an image"),
title: const Text('Open an image'),
),
body: Center(
child: Column(
Expand All @@ -44,7 +46,7 @@ class OpenImagePage extends StatelessWidget {
primary: Colors.blue,
onPrimary: Colors.white,
),
child: Text('Press to open an image file(png, jpg)'),
child: const Text('Press to open an image file(png, jpg)'),
onPressed: () => _openImageFile(context),
),
],
Expand All @@ -56,23 +58,23 @@ class OpenImagePage extends StatelessWidget {

/// Widget that displays a text file in a dialog
class ImageDisplay extends StatelessWidget {
/// Default Constructor
const ImageDisplay(this.fileName, this.filePath);

/// Image's name
final String fileName;

/// Image's path
final String filePath;

/// Default Constructor
ImageDisplay(this.fileName, this.filePath);

@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(fileName),
// On web the filePath is a blob url
// while on other platforms it is a system path.
content: kIsWeb ? Image.network(filePath) : Image.file(File(filePath)),
actions: [
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,41 @@
// found in the LICENSE file.

import 'dart:io';
import 'package:flutter/foundation.dart';

import 'package:file_selector/file_selector.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

/// Screen that shows an example of openFiles
class OpenMultipleImagesPage extends StatelessWidget {
void _openImageFile(BuildContext context) async {
Future<void> _openImageFile(BuildContext context) async {
final XTypeGroup jpgsTypeGroup = XTypeGroup(
label: 'JPEGs',
extensions: ['jpg', 'jpeg'],
extensions: <String>['jpg', 'jpeg'],
);
final XTypeGroup pngTypeGroup = XTypeGroup(
label: 'PNGs',
extensions: ['png'],
extensions: <String>['png'],
);
final List<XFile> files = await openFiles(acceptedTypeGroups: [
final List<XFile> files = await openFiles(acceptedTypeGroups: <XTypeGroup>[
jpgsTypeGroup,
pngTypeGroup,
]);
if (files.isEmpty) {
// Operation was canceled by the user.
return;
}
await showDialog(
await showDialog<void>(
context: context,
builder: (context) => MultipleImagesDisplay(files),
builder: (BuildContext context) => MultipleImagesDisplay(files),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Open multiple images"),
title: const Text('Open multiple images'),
),
body: Center(
child: Column(
Expand All @@ -47,7 +48,7 @@ class OpenMultipleImagesPage extends StatelessWidget {
primary: Colors.blue,
onPrimary: Colors.white,
),
child: Text('Press to open multiple images (png, jpg)'),
child: const Text('Press to open multiple images (png, jpg)'),
onPressed: () => _openImageFile(context),
),
],
Expand All @@ -59,31 +60,31 @@ class OpenMultipleImagesPage extends StatelessWidget {

/// Widget that displays a text file in a dialog
class MultipleImagesDisplay extends StatelessWidget {
/// Default Constructor
const MultipleImagesDisplay(this.files);

/// The files containing the images
final List<XFile> files;

/// Default Constructor
MultipleImagesDisplay(this.files);

@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text('Gallery'),
title: const Text('Gallery'),
// On web the filePath is a blob url
// while on other platforms it is a system path.
content: Center(
child: Row(
children: <Widget>[
...files.map(
(file) => Flexible(
(XFile file) => Flexible(
child: kIsWeb
? Image.network(file.path)
: Image.file(File(file.path))),
)
],
),
),
actions: [
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () {
Expand Down
Loading