Skip to content

Dart analysis-related fixes #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2019
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
5 changes: 0 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

# Root analysis options shared among all Dart code in the respository. Based
# on the Fuchsia standard analysis options, with some changes.
analyzer:
Copy link
Contributor

@krisgiesing krisgiesing Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, there are still strong mode options that aren't the default (see implicit-casts and implicit-dynamic). We're considering trying to turn those on for our project, but they trigger a lot of analysis failures right now.

Copy link
Contributor

@krisgiesing krisgiesing Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! I tried turning them on, and fixed some of the more obvious errors (added to this PR), but some of them were more fiddly, and there aren't easy-to-find example solutions for some of them, so I'm leaving them off for now.

strong-mode: true
language:
enableSuperMixins: true
linter:
# Full list available at http://dart-lang.github.io/linter/lints/options/options.html.
rules:
Expand Down Expand Up @@ -75,7 +71,6 @@ linter:
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_bool_in_asserts
- prefer_collection_literals
- prefer_conditional_assignment
# Disabled until bug is fixed
Expand Down
2 changes: 1 addition & 1 deletion example/flutter_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis_options.yaml
include: ../../analysis_options.yaml
5 changes: 0 additions & 5 deletions example/flutter_app/lib/keyboard_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class _KeyboardTestPageState extends State<KeyboardTestPage> {
final FocusNode _focusNode = FocusNode();
final ScrollController _scrollController = new ScrollController();

@override
void initState() {
super.initState();
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand Down
8 changes: 4 additions & 4 deletions example/flutter_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ class _AppState extends State<MyApp> {
}

class _MyHomePage extends StatelessWidget {
const _MyHomePage({this.title, this.counter = 0});

final String title;
final int counter;

const _MyHomePage({this.title, this.counter = 0});

void _changePrimaryThemeColor(BuildContext context) {
final colorPanel = ColorPanel.instance;
if (!colorPanel.showing) {
colorPanel.show((color) {
_AppState.of(context).setPrimaryColor(color);
// Setting the primary color to a non-opaque color raises an exception.
}, showAlpha: false);
// Setting the primary color to a non-opaque color raises an exception.
}, showAlpha: false);
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/color_panel/lib/color_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ typedef ColorPanelCallback = void Function(Color color);
/// This class is a singleton, since the OS may not allow multiple color panels
/// simultaneously.
class ColorPanel {
ColorPanelCallback _callback;

/// Private constructor.
ColorPanel._() {
_platformChannel.setMethodCallHandler(_wrappedColorPanelCallback);
}

ColorPanelCallback _callback;

/// The static instance of the panel.
static ColorPanel instance = new ColorPanel._();

Expand Down
22 changes: 11 additions & 11 deletions plugins/file_chooser/lib/src/channel_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ enum FileChooserType {

/// A set of configuration options for a file chooser.
class FileChooserConfigurationOptions {
// See channel_constants.h for documentation; these correspond exactly to
// the configuration parameters defined in the channel protocol.
final String initialDirectory; // ignore: public_member_api_docs
final String initialFileName; // ignore: public_member_api_docs
final List<String> allowedFileTypes; // ignore: public_member_api_docs
final bool allowsMultipleSelection; // ignore: public_member_api_docs
final bool canSelectDirectories; // ignore: public_member_api_docs
final String confirmButtonText; // ignore: public_member_api_docs

/// Creates a new configuration options object with the given settings.
const FileChooserConfigurationOptions(
{this.initialDirectory,
Expand All @@ -55,6 +46,15 @@ class FileChooserConfigurationOptions {
this.canSelectDirectories,
this.confirmButtonText});

// See channel_constants.h for documentation; these correspond exactly to
// the configuration parameters defined in the channel protocol.
final String initialDirectory; // ignore: public_member_api_docs
final String initialFileName; // ignore: public_member_api_docs
final List<String> allowedFileTypes; // ignore: public_member_api_docs
final bool allowsMultipleSelection; // ignore: public_member_api_docs
final bool canSelectDirectories; // ignore: public_member_api_docs
final String confirmButtonText; // ignore: public_member_api_docs

/// Returns the configuration as a map that can be passed as the
/// arguments to invokeMethod for [_kShowOpenPanelMethod] or
/// [_kShowSavePanelMethod].
Expand Down Expand Up @@ -87,11 +87,11 @@ class FileChooserConfigurationOptions {

/// A singleton object that controls file-choosing interactions with macOS.
class FileChooserChannelController {
FileChooserChannelController._();

/// The platform channel used to manage native file chooser affordances.
final _channel = new MethodChannel(_kChannelName, new JSONMethodCodec());

FileChooserChannelController._();

/// A reference to the singleton instance of the class.
static final FileChooserChannelController instance =
new FileChooserChannelController._();
Expand Down
10 changes: 5 additions & 5 deletions plugins/menubar/lib/src/menu_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ const String _kDividerKey = 'isDivider';
/// A singleton object that handles the interaction with the menu bar platform
/// channel.
class MenuChannel {
/// Private constructor.
MenuChannel._() {
_platformChannel.setMethodCallHandler(_callbackHandler);
}

final MethodChannel _platformChannel =
const MethodChannel(_kMenuChannelName, const JSONMethodCodec());

Expand All @@ -47,11 +52,6 @@ class MenuChannel {
/// stale callbacks.
bool _updateInProgress;

/// Private constructor.
MenuChannel._() {
_platformChannel.setMethodCallHandler(_callbackHandler);
}

/// The static instance of the menu channel.
static final MenuChannel instance = new MenuChannel._();

Expand Down
24 changes: 12 additions & 12 deletions plugins/menubar/lib/src/menu_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ typedef MenuSelectedCallback = void Function();

/// The base type for an individual menu item that can be shown in a menu.
abstract class AbstractMenuItem {
/// The displayed label for the menu item.
final String label;

/// Creates a new menu item with the give label.
const AbstractMenuItem(this.label);

/// The displayed label for the menu item.
final String label;
}

/// A standard menu item, with no submenus.
class MenuItem extends AbstractMenuItem {
/// The callback to call whenever the menu item is selected.
final MenuSelectedCallback onClicked;

/// Whether or not the menu item is enabled.
final bool enabled;

/// Creates a new menu item with the given [label] and options.
///
/// Note that onClicked should generally be set unless [enabled] is false,
Expand All @@ -42,18 +36,24 @@ class MenuItem extends AbstractMenuItem {
this.enabled = true,
this.onClicked,
}) : super(label);

/// The callback to call whenever the menu item is selected.
final MenuSelectedCallback onClicked;

/// Whether or not the menu item is enabled.
final bool enabled;
}

/// A menu item continaing a submenu.
///
/// The item itself can't be selected, it just displays the submenu.
class Submenu extends AbstractMenuItem {
/// The menu items contained in the submenu.
final List<AbstractMenuItem> children;

/// Creates a new submenu with the given [label] and [children].
const Submenu({@required String label, @required this.children})
: super(label);

/// The menu items contained in the submenu.
final List<AbstractMenuItem> children;
}

/// A menu item that serves as a divider, generally drawn as a line.
Expand Down
22 changes: 12 additions & 10 deletions tools/dart_tools/bin/update_flutter_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ const String engineArchiveBaseUrlString =

/// Simple container for platform-specific information.
class PlatformInfo {
PlatformInfo(this.archiveSubpath, this.libraryFile);

// The subpath on storage.googleapis.com for a platform's engine archive.
final String archiveSubpath;
// The extracted engine library filename for a platform.
final String libraryFile;

PlatformInfo(this.archiveSubpath, this.libraryFile);
}

/// Exceptions for known error cases in updating the engine.
class EngineUpdateException implements Exception {
final String message;
EngineUpdateException(this.message);

final String message;
}

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

if (parsedArguments['help'] || parsedArguments.rest.length != 1) {
if (parsedArguments['help'] != null || parsedArguments.rest.length != 1) {
printUsage(parser);
exit(parsedArguments['help'] ? 0 : 1);
exit(parsedArguments['help'] != null ? 0 : 1);
}

try {
final platform = parsedArguments['platform'];
final String platform = parsedArguments['platform'];
final outputRoot =
path.canonicalize(path.absolute(parsedArguments.rest[0]));
final targetHash = parsedArguments['hash'] ??
final String targetHash = parsedArguments['hash'] ??
await engineHashForFlutterTree(parsedArguments['flutter_root']);
final libraryFile = platformInfo[platform].libraryFile;

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