Skip to content

Commit 8468869

Browse files
Merge pull request #1800 from miguelpruivo/feature/restore-linter-on-example-project
Restore Linter on example's project
2 parents 968edff + 15cfad6 commit 8468869

File tree

3 files changed

+19
-58
lines changed

3 files changed

+19
-58
lines changed

analysis_options.yaml

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1 @@
1-
include: package:lints/recommended.yaml
2-
3-
analyzer:
4-
exclude:
5-
- build/**
6-
- example/**
7-
- lib/generated_plugin_registrant.dart
8-
# language:
9-
# strict-raw-types: true
10-
# strong-mode:
11-
# implicit-casts: false
12-
13-
linter:
14-
rules:
15-
# - cancel_subscriptions
16-
- comment_references
17-
- slash_for_doc_comments
18-
- use_key_in_widget_constructors
19-
- unnecessary_statements
20-
- throw_in_finally
21-
- always_use_package_imports
22-
- avoid_dynamic_calls
23-
- avoid_empty_else
24-
# - avoid_print
25-
- avoid_relative_lib_imports
26-
- avoid_slow_async_io
27-
- avoid_type_to_string
28-
- avoid_types_as_parameter_names
29-
- avoid_web_libraries_in_flutter
30-
- cancel_subscriptions
31-
- close_sinks
32-
- control_flow_in_finally
33-
- diagnostic_describe_all_properties
34-
- empty_statements
35-
- hash_and_equals
36-
- collection_methods_unrelated_type
37-
- literal_only_boolean_expressions
38-
- no_adjacent_strings_in_list
39-
- no_duplicate_case_values
40-
- no_logic_in_create_state
41-
- prefer_void_to_null
42-
- test_types_in_equals
1+
include: package:lints/recommended.yaml

example/lib/src/file_picker_demo.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import 'dart:convert';
2-
31
import 'package:file/local.dart';
42
import 'package:file_picker/file_picker.dart';
53
import 'package:flutter/foundation.dart';
64
import 'package:flutter/material.dart';
75
import 'package:flutter/services.dart';
86

97
class FilePickerDemo extends StatefulWidget {
8+
const FilePickerDemo({super.key});
9+
1010
@override
11-
_FilePickerDemoState createState() => _FilePickerDemoState();
11+
State<FilePickerDemo> createState() => _FilePickerDemoState();
1212
}
1313

1414
class _FilePickerDemoState extends State<FilePickerDemo> {
@@ -36,7 +36,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
3636
Icons.error_outline,
3737
),
3838
contentPadding: EdgeInsets.symmetric(vertical: 40.0),
39-
title: const Text('No action taken yet'),
39+
title: Text('No action taken yet'),
4040
subtitle: Text(
4141
'Please use on one of the buttons above to get started',
4242
style: TextStyle(
@@ -80,7 +80,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
8080
pickedFiles = (await FilePicker.platform.pickFiles(
8181
type: _pickingType,
8282
allowMultiple: _multiPick,
83-
onFileLoading: (FilePickerStatus status) => print(status),
83+
onFileLoading: (FilePickerStatus status) => printInDebug(status),
8484
allowedExtensions: (_extension?.isNotEmpty ?? false)
8585
? _extension?.replaceAll(' ', '').split(',')
8686
: null,
@@ -92,7 +92,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
9292
?.files;
9393
hasUserAborted = pickedFiles == null;
9494
} on PlatformException catch (e) {
95-
_logException('Unsupported operation' + e.toString());
95+
_logException('Unsupported operation: $e');
9696
} catch (e) {
9797
_logException(e.toString());
9898
}
@@ -135,7 +135,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
135135
);
136136
hasUserAborted = pickedFilesAndDirectories == null;
137137
} on PlatformException catch (e) {
138-
_logException('Unsupported operation' + e.toString());
138+
_logException('Unsupported operation: $e');
139139
} catch (e) {
140140
_logException(e.toString());
141141
}
@@ -185,7 +185,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
185185
),
186186
);
187187
} on PlatformException catch (e) {
188-
_logException('Unsupported operation' + e.toString());
188+
_logException('Unsupported operation: $e');
189189
} catch (e) {
190190
_logException(e.toString());
191191
}
@@ -207,7 +207,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
207207
);
208208
hasUserAborted = pickedDirectoryPath == null;
209209
} on PlatformException catch (e) {
210-
_logException('Unsupported operation' + e.toString());
210+
_logException('Unsupported operation: $e');
211211
} catch (e) {
212212
_logException(e.toString());
213213
}
@@ -247,7 +247,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
247247
);
248248
hasUserAborted = pickedSaveFilePath == null;
249249
} on PlatformException catch (e) {
250-
_logException('Unsupported operation' + e.toString());
250+
_logException('Unsupported operation: $e');
251251
} catch (e) {
252252
_logException(e.toString());
253253
}
@@ -269,7 +269,7 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
269269
}
270270

271271
void _logException(String message) {
272-
print(message);
272+
printInDebug(message);
273273
_scaffoldMessengerKey.currentState?.hideCurrentSnackBar();
274274
_scaffoldMessengerKey.currentState?.showSnackBar(
275275
SnackBar(
@@ -373,8 +373,8 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
373373
items: FileType.values
374374
.map(
375375
(fileType) => DropdownMenuItem<FileType>(
376-
child: Text(fileType.toString()),
377376
value: fileType,
377+
child: Text(fileType.toString()),
378378
),
379379
)
380380
.toList(),
@@ -569,4 +569,6 @@ class _FilePickerDemoState extends State<FilePickerDemo> {
569569
),
570570
);
571571
}
572+
573+
void printInDebug(Object object) => debugPrint(object.toString());
572574
}

example/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
name: file_picker_example
22
description: An example of how to use the file_picker plugin.
3-
version: 1.0.0+1
3+
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
44

55
environment:
66
sdk: ">=2.19.0 <4.0.0"
77

88
dependencies:
99
flutter:
1010
sdk: flutter
11+
file_picker:
12+
path: ../
1113
file: ^7.0.1
1214

1315
dev_dependencies:
1416
flutter_test:
1517
sdk: flutter
16-
17-
file_picker:
18-
path: ../
18+
flutter_lints: ^5.0.0
1919

2020
flutter:
2121
uses-material-design: true

0 commit comments

Comments
 (0)