Skip to content

Commit

Permalink
fix: Update to support dart 3.0 and fix analyze issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
GSMLG-BOT committed Jul 27, 2023
1 parent b43a964 commit c43b159
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 74 deletions.
41 changes: 4 additions & 37 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,49 +1,17 @@
# Specify analysis options.
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.

analyzer:
strong-mode:
implicit-dynamic: false
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
# allow having TODOs in the code
todo: ignore
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
sdk_version_async_exported_from_core: ignore
exclude:
- 'bin/cache/**'
# the following two are relative to the stocks example and the flutter package respectively
# see https://github.com/dart-lang/sdk/issues/28463
- 'lib/i18n/stock_messages_*.dart'
- 'lib/src/http/**'
- 'example/**'
- "bin/cache/**"
- "lib/i18n/stock_messages_*.dart"
- "lib/src/http/**"
- "example/**"

linter:
rules:
# these rules are documented on and in the same order as
# the Dart Lint rules page to make maintenance easier
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
- always_declare_return_types
- always_put_control_body_on_new_line
Expand Down Expand Up @@ -128,7 +96,6 @@ linter:
- prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # not yet tested
- prefer_contains
- prefer_equal_for_default_values
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
- prefer_final_fields
- prefer_final_locals
Expand Down
8 changes: 4 additions & 4 deletions lib/android.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:io';
import 'package:flutter_launcher_icons_maker/utils.dart';
import 'package:flutter_launcher_icons_maker/xml_templates.dart' as xml_template;
import 'package:image/image.dart';

import 'package:flutter_launcher_icons_maker/custom_exceptions.dart';
import 'package:flutter_launcher_icons_maker/abstract_platform.dart';
import 'package:flutter_launcher_icons_maker/constants.dart' as constants;
import 'package:flutter_launcher_icons_maker/custom_exceptions.dart';
import 'package:flutter_launcher_icons_maker/utils.dart';
import 'package:flutter_launcher_icons_maker/xml_templates.dart' as xml_template;
import 'package:image/image.dart';

class AndroidIconTemplate {
AndroidIconTemplate({required this.size, required this.directoryName});
Expand Down
5 changes: 1 addition & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import 'package:path/path.dart' as path;
import 'package:yaml/yaml.dart';

import 'abstract_platform.dart';
import 'android.dart' as android_launcher_icons;
import 'constants.dart';
import 'custom_exceptions.dart';

import 'android.dart' as android_launcher_icons;
import 'ios.dart' as ios_launcher_icons;
import 'macos.dart' as macos_launcher_icons;
import 'web.dart' as web_launcher_icons;
Expand Down Expand Up @@ -190,7 +189,6 @@ Map<String, dynamic> loadConfigFile(String path, String? fileOptionResult) {
return config;
}


bool isConfigValid(Map<String, dynamic> flutterIconsConfig) {
for (final AbstractPlatform platform in platforms.values) {
final String? complaint = platform.isConfigValid(flutterIconsConfig);
Expand All @@ -210,4 +208,3 @@ bool hasPlatformConfig(Map<String, dynamic> flutterIconsConfig) {
}
return false;
}

2 changes: 0 additions & 2 deletions lib/utils.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:io';

import 'package:image/image.dart';

import 'custom_exceptions.dart';

Image createResizedImage(int iconSize, Image image) {
if (image.width >= iconSize) {
Expand Down
3 changes: 2 additions & 1 deletion lib/web.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:io';

import 'package:flutter_launcher_icons_maker/abstract_platform.dart';
import 'package:flutter_launcher_icons_maker/constants.dart' as constants;
import 'package:flutter_launcher_icons_maker/icon_template.dart';
import 'package:flutter_launcher_icons_maker/utils.dart';
import 'package:image/image.dart';
import 'package:flutter_launcher_icons_maker/constants.dart' as constants;

final IconTemplateGenerator iconGenerator =
IconTemplateGenerator(defaultLocation: constants.webIconLocation);
Expand Down
29 changes: 15 additions & 14 deletions lib/windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ class WindowsIconGenerator extends AbstractPlatform {
}

Future<void> _updateResources(String iconName, String? flavor) async {
final String filePathOriginalH = windowsRunnerFolder + 'resource.h';
final String filePathOriginalRC = windowsRunnerFolder + 'runner.rc';
final String filePathOriginalCPP = windowsRunnerFolder + 'win32_window.cpp';
const String filePathOriginalH = windowsRunnerFolder + 'resource.h';
const String filePathOriginalRC = windowsRunnerFolder + 'runner.rc';
const String filePathOriginalCPP = windowsRunnerFolder + 'win32_window.cpp';

final String? flavorName = flavor != null ? '-' + flavor : '';

Expand All @@ -119,7 +119,7 @@ class WindowsIconGenerator extends AbstractPlatform {
final List<String> newAppIconsSectionH = [];
final List<String> newAppIconsSectionRC = [];
int idiNumber = 101;
windowsIcons.forEach((iconType) {
for (var iconType in windowsIcons) {
final String idi =
'IDI_${iconName.toUpperCase()}$flavorName${iconType.baseName}';

Expand All @@ -128,7 +128,7 @@ class WindowsIconGenerator extends AbstractPlatform {
'$idi ICON \"$windowsAssetFolder/$iconName${iconType.name}\"');

idiNumber += 1;
});
}

// Write new resource.h in buffer
final bufferNewResourcesH = StringBuffer();
Expand All @@ -139,15 +139,15 @@ class WindowsIconGenerator extends AbstractPlatform {
// Stop copying when receiving idis
if (doKeep) {
doKeep = false;
newAppIconsSectionH.forEach((line) {
bufferNewResourcesH.writeln(line);
});
newAppIconsSectionH.forEach(bufferNewResourcesH.writeln);
// Insert newly created idis
}
}
if (line == '')
doKeep = true; // Start copying again with the first blank line
if (doKeep) bufferNewResourcesH.writeln(line);
if (doKeep) {
bufferNewResourcesH.writeln(line);
}
}

// write new header from buffer to file
Expand All @@ -164,15 +164,15 @@ class WindowsIconGenerator extends AbstractPlatform {
// Stop copying when receiving idis
if (doKeep) {
doKeep = false;
newAppIconsSectionRC.forEach((line) {
bufferNewResourcesRC.writeln(line);
});
newAppIconsSectionRC.forEach(bufferNewResourcesRC.writeln);
// Insert newly created resources
}
}
if (line == '')
doKeep = true; // Start copying again with the first blank line
if (doKeep) bufferNewResourcesRC.writeln(line);
if (doKeep) {
bufferNewResourcesRC.writeln(line);
}
}
final File newResourcesRC = File(filePathOriginalRC);
await newResourcesRC.writeAsString(bufferNewResourcesRC.toString(),
Expand All @@ -190,8 +190,9 @@ class WindowsIconGenerator extends AbstractPlatform {
newLoadIcon +=
'LoadIcon(window_class.hInstance, MAKEINTRESOURCE($baseIdi));';
bufferNewResourcesCPP.writeln(newLoadIcon);
if (line != newLoadIcon)
if (line != newLoadIcon) {
needRewriteCPP = true;
}
// Insert newly created resources
} else
bufferNewResourcesCPP.writeln(line);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ homepage: https://github.com/gsmlg-dev/flutter_launcher_icons_maker

dependencies:
args: ^2.2.0
image: ^3.0.2
image: ^4.0.0
path: ^1.8.0
yaml: ^3.1.0

environment:
sdk: '>=2.15.1 <3.0.0'
sdk: ">=2.15.1 <4.0.0"

dev_dependencies:
test: ^1.17.11
22 changes: 12 additions & 10 deletions test/main_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'dart:io';

import 'package:args/args.dart';
import 'package:test/test.dart';
import 'package:yaml/yaml.dart' as yaml;
import 'package:path/path.dart' as pathlib;
import 'package:flutter_launcher_icons_maker/ios.dart' as ios;
import 'package:flutter_launcher_icons_maker/android.dart' as android;
import 'package:flutter_launcher_icons_maker/main.dart' as main_dart;
import 'package:flutter_launcher_icons_maker/constants.dart' as constants;
import 'package:flutter_launcher_icons_maker/ios.dart' as ios;
import 'package:flutter_launcher_icons_maker/main.dart' as main_dart;
import 'package:path/path.dart' as pathlib;
import 'package:test/test.dart';
import 'package:yaml/yaml.dart' as yaml;

// Unit tests for main.dart
void main() {
Expand Down Expand Up @@ -80,7 +80,7 @@ flutter_icons:

// fails if forcing default file
argResults = parser.parse(<String>['-f', constants.defaultConfigFile]);
expect(loadConfig(argResults), {});
expect(loadConfig(argResults), <String, dynamic>{});
});

test('custom', () async {
Expand All @@ -97,11 +97,11 @@ flutter_icons:

// should fail if no argument
argResults = parser.parse(<String>[]);
expect(loadConfig(argResults), {});
expect(loadConfig(argResults), <String, dynamic>{});

// or missing file
argResults = parser.parse(<String>['-f', 'missing_custom.yaml']);
expect(loadConfig(argResults), {});
expect(loadConfig(argResults), <String, dynamic>{});
});
});

Expand Down Expand Up @@ -251,7 +251,8 @@ flutter_icons:

test('Version code regexp works.', () {
expect(versionCodeExp.firstMatch('#### 0.0.1 (3rd Oct 2020)'), isNotNull);
expect(versionCodeExp.firstMatch('#### 0.0.1 (A Placeholder Date)'), isNotNull);
expect(versionCodeExp.firstMatch('#### 0.0.1 (A Placeholder Date)'),
isNotNull);
expect(versionCodeExp.firstMatch('Not a version code.'), isNull);
expect(versionCodeExp.firstMatch('## Not a version code'), isNull);
expect(versionCodeExp.firstMatch('## 4.4 is not a .0 version'), isNull);
Expand All @@ -267,7 +268,8 @@ flutter_icons:
isNotNull);
});

test('pubspec.yaml version code matches the built-in version code.', () async {
test('pubspec.yaml version code matches the built-in version code.',
() async {
final File pubspec = File('pubspec.yaml');
final String pubspecContent = await pubspec.readAsString();
final yaml.YamlMap yamlContent = yaml.loadYaml(pubspecContent);
Expand Down

0 comments on commit c43b159

Please sign in to comment.