Skip to content

Commit 0e59304

Browse files
authored
Dart analysis-related fixes (#211)
* Dart analysis-related fixes - Fixes the include path for the example app's analysis file, which broke during the repository restructure. - Removes analysis options that are obsolete in recent Dart versions. - Fix some new analysis issues (mostly constructor ordering).
1 parent cf3a791 commit 0e59304

File tree

9 files changed

+47
-55
lines changed

9 files changed

+47
-55
lines changed

analysis_options.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
# Root analysis options shared among all Dart code in the respository. Based
66
# on the Fuchsia standard analysis options, with some changes.
7-
analyzer:
8-
strong-mode: true
9-
language:
10-
enableSuperMixins: true
117
linter:
128
# Full list available at http://dart-lang.github.io/linter/lints/options/options.html.
139
rules:
@@ -75,7 +71,6 @@ linter:
7571
- parameter_assignments
7672
- prefer_adjacent_string_concatenation
7773
- prefer_asserts_in_initializer_lists
78-
- prefer_bool_in_asserts
7974
- prefer_collection_literals
8075
- prefer_conditional_assignment
8176
# Disabled until bug is fixed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: ../analysis_options.yaml
1+
include: ../../analysis_options.yaml

example/flutter_app/lib/keyboard_test_page.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class _KeyboardTestPageState extends State<KeyboardTestPage> {
2929
final FocusNode _focusNode = FocusNode();
3030
final ScrollController _scrollController = new ScrollController();
3131

32-
@override
33-
void initState() {
34-
super.initState();
35-
}
36-
3732
@override
3833
void didChangeDependencies() {
3934
super.didChangeDependencies();

example/flutter_app/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ class _AppState extends State<MyApp> {
140140
}
141141

142142
class _MyHomePage extends StatelessWidget {
143+
const _MyHomePage({this.title, this.counter = 0});
144+
143145
final String title;
144146
final int counter;
145147

146-
const _MyHomePage({this.title, this.counter = 0});
147-
148148
void _changePrimaryThemeColor(BuildContext context) {
149149
final colorPanel = ColorPanel.instance;
150150
if (!colorPanel.showing) {
151151
colorPanel.show((color) {
152152
_AppState.of(context).setPrimaryColor(color);
153-
// Setting the primary color to a non-opaque color raises an exception.
154-
}, showAlpha: false);
153+
// Setting the primary color to a non-opaque color raises an exception.
154+
}, showAlpha: false);
155155
}
156156
}
157157

plugins/color_panel/lib/color_panel.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ typedef ColorPanelCallback = void Function(Color color);
4040
/// This class is a singleton, since the OS may not allow multiple color panels
4141
/// simultaneously.
4242
class ColorPanel {
43-
ColorPanelCallback _callback;
44-
4543
/// Private constructor.
4644
ColorPanel._() {
4745
_platformChannel.setMethodCallHandler(_wrappedColorPanelCallback);
4846
}
4947

48+
ColorPanelCallback _callback;
49+
5050
/// The static instance of the panel.
5151
static ColorPanel instance = new ColorPanel._();
5252

plugins/file_chooser/lib/src/channel_controller.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@ enum FileChooserType {
3737

3838
/// A set of configuration options for a file chooser.
3939
class FileChooserConfigurationOptions {
40-
// See channel_constants.h for documentation; these correspond exactly to
41-
// the configuration parameters defined in the channel protocol.
42-
final String initialDirectory; // ignore: public_member_api_docs
43-
final String initialFileName; // ignore: public_member_api_docs
44-
final List<String> allowedFileTypes; // ignore: public_member_api_docs
45-
final bool allowsMultipleSelection; // ignore: public_member_api_docs
46-
final bool canSelectDirectories; // ignore: public_member_api_docs
47-
final String confirmButtonText; // ignore: public_member_api_docs
48-
4940
/// Creates a new configuration options object with the given settings.
5041
const FileChooserConfigurationOptions(
5142
{this.initialDirectory,
@@ -55,6 +46,15 @@ class FileChooserConfigurationOptions {
5546
this.canSelectDirectories,
5647
this.confirmButtonText});
5748

49+
// See channel_constants.h for documentation; these correspond exactly to
50+
// the configuration parameters defined in the channel protocol.
51+
final String initialDirectory; // ignore: public_member_api_docs
52+
final String initialFileName; // ignore: public_member_api_docs
53+
final List<String> allowedFileTypes; // ignore: public_member_api_docs
54+
final bool allowsMultipleSelection; // ignore: public_member_api_docs
55+
final bool canSelectDirectories; // ignore: public_member_api_docs
56+
final String confirmButtonText; // ignore: public_member_api_docs
57+
5858
/// Returns the configuration as a map that can be passed as the
5959
/// arguments to invokeMethod for [_kShowOpenPanelMethod] or
6060
/// [_kShowSavePanelMethod].
@@ -87,11 +87,11 @@ class FileChooserConfigurationOptions {
8787

8888
/// A singleton object that controls file-choosing interactions with macOS.
8989
class FileChooserChannelController {
90+
FileChooserChannelController._();
91+
9092
/// The platform channel used to manage native file chooser affordances.
9193
final _channel = new MethodChannel(_kChannelName, new JSONMethodCodec());
9294

93-
FileChooserChannelController._();
94-
9595
/// A reference to the singleton instance of the class.
9696
static final FileChooserChannelController instance =
9797
new FileChooserChannelController._();

plugins/menubar/lib/src/menu_channel.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ const String _kDividerKey = 'isDivider';
3030
/// A singleton object that handles the interaction with the menu bar platform
3131
/// channel.
3232
class MenuChannel {
33+
/// Private constructor.
34+
MenuChannel._() {
35+
_platformChannel.setMethodCallHandler(_callbackHandler);
36+
}
37+
3338
final MethodChannel _platformChannel =
3439
const MethodChannel(_kMenuChannelName, const JSONMethodCodec());
3540

@@ -47,11 +52,6 @@ class MenuChannel {
4752
/// stale callbacks.
4853
bool _updateInProgress;
4954

50-
/// Private constructor.
51-
MenuChannel._() {
52-
_platformChannel.setMethodCallHandler(_callbackHandler);
53-
}
54-
5555
/// The static instance of the menu channel.
5656
static final MenuChannel instance = new MenuChannel._();
5757

plugins/menubar/lib/src/menu_item.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@ typedef MenuSelectedCallback = void Function();
1818

1919
/// The base type for an individual menu item that can be shown in a menu.
2020
abstract class AbstractMenuItem {
21-
/// The displayed label for the menu item.
22-
final String label;
23-
2421
/// Creates a new menu item with the give label.
2522
const AbstractMenuItem(this.label);
23+
24+
/// The displayed label for the menu item.
25+
final String label;
2626
}
2727

2828
/// A standard menu item, with no submenus.
2929
class MenuItem extends AbstractMenuItem {
30-
/// The callback to call whenever the menu item is selected.
31-
final MenuSelectedCallback onClicked;
32-
33-
/// Whether or not the menu item is enabled.
34-
final bool enabled;
35-
3630
/// Creates a new menu item with the given [label] and options.
3731
///
3832
/// Note that onClicked should generally be set unless [enabled] is false,
@@ -42,18 +36,24 @@ class MenuItem extends AbstractMenuItem {
4236
this.enabled = true,
4337
this.onClicked,
4438
}) : super(label);
39+
40+
/// The callback to call whenever the menu item is selected.
41+
final MenuSelectedCallback onClicked;
42+
43+
/// Whether or not the menu item is enabled.
44+
final bool enabled;
4545
}
4646

4747
/// A menu item continaing a submenu.
4848
///
4949
/// The item itself can't be selected, it just displays the submenu.
5050
class Submenu extends AbstractMenuItem {
51-
/// The menu items contained in the submenu.
52-
final List<AbstractMenuItem> children;
53-
5451
/// Creates a new submenu with the given [label] and [children].
5552
const Submenu({@required String label, @required this.children})
5653
: super(label);
54+
55+
/// The menu items contained in the submenu.
56+
final List<AbstractMenuItem> children;
5757
}
5858

5959
/// A menu item that serves as a divider, generally drawn as a line.

tools/dart_tools/bin/update_flutter_engine.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ const String engineArchiveBaseUrlString =
3232

3333
/// Simple container for platform-specific information.
3434
class PlatformInfo {
35+
PlatformInfo(this.archiveSubpath, this.libraryFile);
36+
3537
// The subpath on storage.googleapis.com for a platform's engine archive.
3638
final String archiveSubpath;
3739
// The extracted engine library filename for a platform.
3840
final String libraryFile;
39-
40-
PlatformInfo(this.archiveSubpath, this.libraryFile);
4141
}
4242

4343
/// Exceptions for known error cases in updating the engine.
4444
class EngineUpdateException implements Exception {
45-
final String message;
4645
EngineUpdateException(this.message);
46+
47+
final String message;
4748
}
4849

4950
/// PlatformInfo for each supported platform.
@@ -83,16 +84,16 @@ Future<void> main(List<String> arguments) async {
8384
exit(1);
8485
}
8586

86-
if (parsedArguments['help'] || parsedArguments.rest.length != 1) {
87+
if (parsedArguments['help'] != null || parsedArguments.rest.length != 1) {
8788
printUsage(parser);
88-
exit(parsedArguments['help'] ? 0 : 1);
89+
exit(parsedArguments['help'] != null ? 0 : 1);
8990
}
9091

9192
try {
92-
final platform = parsedArguments['platform'];
93+
final String platform = parsedArguments['platform'];
9394
final outputRoot =
9495
path.canonicalize(path.absolute(parsedArguments.rest[0]));
95-
final targetHash = parsedArguments['hash'] ??
96+
final String targetHash = parsedArguments['hash'] ??
9697
await engineHashForFlutterTree(parsedArguments['flutter_root']);
9798
final libraryFile = platformInfo[platform].libraryFile;
9899

@@ -213,7 +214,8 @@ Future<void> extractEngineArchive(
213214
// Unwrap the outer zip via Archive to avoid starting an extra process.
214215
final isDoubleZipped =
215216
archive.numberOfFiles() == 1 && archive[0].name.endsWith('.zip');
216-
final innermostZipData = isDoubleZipped ? archive[0].content : archiveData;
217+
final List<int> innermostZipData =
218+
isDoubleZipped ? archive[0].content : archiveData;
217219
await unzipMacOSEngineFramework(innermostZipData, outputDirectory);
218220
} else {
219221
// Windows and Linux have flat archives, so can be easily extracted via
@@ -249,8 +251,8 @@ Future<void> unzipMacOSEngineFramework(
249251
// Temporarily write the data to a file, since unzip doesn't accept piped
250252
// input, then delete the file.
251253
await temporaryArchiveFile.writeAsBytes(archiveData);
252-
final result = await Process
253-
.run('/usr/bin/unzip', [temporaryArchiveFile.path, '-d', targetPath]);
254+
final result = await Process.run(
255+
'/usr/bin/unzip', [temporaryArchiveFile.path, '-d', targetPath]);
254256
await temporaryArchiveFile.delete();
255257
if (result.exitCode != 0) {
256258
throw new EngineUpdateException(

0 commit comments

Comments
 (0)