diff --git a/.idea/.gitignore b/.idea/.gitignore index 5007a1d97..027f0d381 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -6,4 +6,5 @@ /dictionaries/ /libraries/ /runConfigurations/melos_* +/shelf/ /*.xml diff --git a/.tool-versions b/.tool-versions index 62f61e588..ad0cea1b9 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -flutter 3.27.1-stable +flutter 3.27.2-stable diff --git a/examples/example/lib/gen/assets.gen.dart b/examples/example/lib/gen/assets.gen.dart index 1ec196fce..21a2ef0a6 100644 --- a/examples/example/lib/gen/assets.gen.dart +++ b/examples/example/lib/gen/assets.gen.dart @@ -99,12 +99,12 @@ class $AssetsLottieGen { /// List of all assets List get values => [ - xuiIZ9X1Rf, - alarmClockLottieV440, - geometricalAnimation, - hamburgerArrow, - spinningCarrousel, - ]; + xuiIZ9X1Rf, + alarmClockLottieV440, + geometricalAnimation, + hamburgerArrow, + spinningCarrousel, + ]; } class $AssetsMixGen { diff --git a/packages/core/lib/flutter_generator.dart b/packages/core/lib/flutter_generator.dart index 33c6af26a..2ac6e4f82 100644 --- a/packages/core/lib/flutter_generator.dart +++ b/packages/core/lib/flutter_generator.dart @@ -1,4 +1,4 @@ -import 'dart:io' show stdout, Directory, File, Platform; +import 'dart:io' show stdout, Directory, File; import 'package:dart_style/dart_style.dart' show DartFormatter; import 'package:flutter_gen_core/generators/assets_generator.dart'; @@ -7,7 +7,6 @@ import 'package:flutter_gen_core/generators/fonts_generator.dart'; import 'package:flutter_gen_core/settings/config.dart'; import 'package:flutter_gen_core/utils/file.dart'; import 'package:path/path.dart' show join, normalize; -import 'package:pub_semver/pub_semver.dart' show Version; class FlutterGenerator { const FlutterGenerator( @@ -33,7 +32,7 @@ class FlutterGenerator { final output = config.pubspec.flutterGen.output; final lineLength = config.pubspec.flutterGen.lineLength; final formatter = DartFormatter( - languageVersion: Version.parse(Platform.version.split(' ').first), + languageVersion: DartFormatter.latestLanguageVersion, pageWidth: lineLength, lineEnding: '\n', ); diff --git a/packages/core/lib/generators/integrations/image_integration.dart b/packages/core/lib/generators/integrations/image_integration.dart index 1de34fe79..6ed73fcda 100644 --- a/packages/core/lib/generators/integrations/image_integration.dart +++ b/packages/core/lib/generators/integrations/image_integration.dart @@ -59,8 +59,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} bool matchTextDirection = false, bool gaplessPlayback = true, bool isAntiAlias = false, - ${isPackage ? deprecationMessagePackage : ''} - String? package$packageParameter, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, FilterQuality filterQuality = FilterQuality.medium, int? cacheWidth, int? cacheHeight, @@ -95,8 +94,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} ImageProvider provider({ AssetBundle? bundle, - ${isPackage ? deprecationMessagePackage : ''} - String? package$packageParameter, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageParameter, }) { return AssetImage( _assetName, @@ -157,7 +155,10 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} /// Extract metadata from the asset. ImageMetadata? _getMetadata(AssetType asset) { try { - final size = ImageSizeGetter.getSize(FileInput(File(asset.fullPath))); + final result = ImageSizeGetter.getSizeResult( + FileInput(File(asset.fullPath)), + ); + final size = result.size; return ImageMetadata(size.width.toDouble(), size.height.toDouble()); } catch (e) { stderr diff --git a/packages/core/lib/generators/integrations/lottie_integration.dart b/packages/core/lib/generators/integrations/lottie_integration.dart index 82362f289..cb8ab27b3 100644 --- a/packages/core/lib/generators/integrations/lottie_integration.dart +++ b/packages/core/lib/generators/integrations/lottie_integration.dart @@ -70,8 +70,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} double? height, BoxFit? fit, AlignmentGeometry? alignment, - ${isPackage ? deprecationMessagePackage : ''} - String? package$packageExpression, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageExpression, bool? addRepaintBoundary, FilterQuality? filterQuality, void Function(String)? onWarning, diff --git a/packages/core/lib/generators/integrations/svg_integration.dart b/packages/core/lib/generators/integrations/svg_integration.dart index 212f28167..ac44c9e9b 100644 --- a/packages/core/lib/generators/integrations/svg_integration.dart +++ b/packages/core/lib/generators/integrations/svg_integration.dart @@ -44,8 +44,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''} Key? key, bool matchTextDirection = false, AssetBundle? bundle, - ${isPackage ? deprecationMessagePackage : ''} - String? package$packageExpression, + ${isPackage ? '$deprecationMessagePackage\n' : ''}String? package$packageExpression, double? width, double? height, BoxFit fit = BoxFit.contain, diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index 81af5bb6d..b68708cea 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -29,7 +29,7 @@ dependencies: args: ^2.0.0 pub_semver: ^2.0.0 vector_graphics_compiler: ^1.1.9 - image_size_getter: ^2.1.2 + image_size_getter: ^2.4.0 dev_dependencies: lints: any # Ignoring the version to allow editing across SDK versions. diff --git a/packages/core/test/assets_gen_test.dart b/packages/core/test/assets_gen_test.dart index e93adf4f9..29ff06c42 100644 --- a/packages/core/test/assets_gen_test.dart +++ b/packages/core/test/assets_gen_test.dart @@ -60,7 +60,7 @@ void main() { final pubspec = File('test_resources/pubspec_assets_no_list.yaml'); final config = loadPubspecConfig(pubspec); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); @@ -103,9 +103,12 @@ void main() { }); test('Assets with directory path and package parameter enabled', () async { - const pubspec = 'test_resources/pubspec_assets_directory_path_with_package_parameter.yaml'; - const fact = 'test_resources/actual_data/assets_directory_path_with_package_parameter.gen.dart'; - const generated = 'test_resources/lib/gen/assets_directory_path_with_package_parameter.gen.dart'; + const pubspec = + 'test_resources/pubspec_assets_directory_path_with_package_parameter.yaml'; + const fact = + 'test_resources/actual_data/assets_directory_path_with_package_parameter.gen.dart'; + const generated = + 'test_resources/lib/gen/assets_directory_path_with_package_parameter.gen.dart'; await expectedAssetsGen(pubspec, generated, fact); }); @@ -271,8 +274,9 @@ void main() { buildFile.writeAsStringSync( File('test_resources/build_assets.yaml').readAsStringSync(), ); - await expectedAssetsGen(pubspec, generated, fact); - buildFile.writeAsStringSync(originalBuildContent); + await expectedAssetsGen(pubspec, generated, fact).whenComplete(() { + buildFile.writeAsStringSync(originalBuildContent); + }); }); }); diff --git a/packages/core/test/colors_gen_test.dart b/packages/core/test/colors_gen_test.dart index 1d9357bb3..968f656dc 100644 --- a/packages/core/test/colors_gen_test.dart +++ b/packages/core/test/colors_gen_test.dart @@ -23,7 +23,7 @@ void main() { final pubspec = File('test_resources/pubspec_colors_no_inputs.yaml'); final config = loadPubspecConfig(pubspec); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); @@ -38,7 +38,7 @@ void main() { final pubspec = File('test_resources/pubspec_colors_no_inputs_list.yaml'); final config = loadPubspecConfig(pubspec); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); diff --git a/packages/core/test/fonts_gen_test.dart b/packages/core/test/fonts_gen_test.dart index e13ed5ea1..cd399a023 100644 --- a/packages/core/test/fonts_gen_test.dart +++ b/packages/core/test/fonts_gen_test.dart @@ -23,7 +23,7 @@ void main() { File('test_resources/pubspec_fonts_no_family.yaml'), ); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); diff --git a/packages/core/test/gen_test_helper.dart b/packages/core/test/gen_test_helper.dart index 2b3060711..4c6b45555 100644 --- a/packages/core/test/gen_test_helper.dart +++ b/packages/core/test/gen_test_helper.dart @@ -7,10 +7,9 @@ import 'package:flutter_gen_core/generators/colors_generator.dart'; import 'package:flutter_gen_core/generators/fonts_generator.dart'; import 'package:flutter_gen_core/settings/config.dart'; import 'package:path/path.dart' as p; -import 'package:pub_semver/pub_semver.dart' show Version; import 'package:test/test.dart'; -final currentDartVersion = Version.parse(Platform.version.split(' ').first); +final dartFormatterLanguageVersion = DartFormatter.latestLanguageVersion; Future clearTestResults() async {} @@ -35,7 +34,7 @@ Future> runAssetsGen( stdout.writeln('[DEBUG] test: Generate from API...'); final config = loadPubspecConfig(pubspecFile, buildFile: buildFile); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); @@ -79,7 +78,7 @@ Future> runColorsGen( final pubspecFile = File(pubspec); final config = loadPubspecConfig(pubspecFile); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); @@ -123,7 +122,7 @@ Future> runFontsGen( final pubspecFile = File(pubspec); final config = loadPubspecConfig(pubspecFile); final formatter = DartFormatter( - languageVersion: currentDartVersion, + languageVersion: dartFormatterLanguageVersion, pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n', ); diff --git a/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart index a57b09d89..b92747675 100644 --- a/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart @@ -26,8 +26,11 @@ class $AssetsLottieGen { const LottieGenImage('assets/lottie/spinning_carrousel.zip'); /// List of all assets - List get values => - [xuiIZ9X1Rf, hamburgerArrow, spinningCarrousel]; + List get values => [ + xuiIZ9X1Rf, + hamburgerArrow, + spinningCarrousel, + ]; } class Assets { @@ -37,10 +40,7 @@ class Assets { } class LottieGenImage { - const LottieGenImage( - this._assetName, { - this.flavors = const {}, - }); + const LottieGenImage(this._assetName, {this.flavors = const {}}); final String _assetName; final Set flavors; @@ -57,11 +57,8 @@ class LottieGenImage { _lottie.LottieImageProviderFactory? imageProviderFactory, Key? key, AssetBundle? bundle, - Widget Function( - BuildContext, - Widget, - _lottie.LottieComposition?, - )? frameBuilder, + Widget Function(BuildContext, Widget, _lottie.LottieComposition?)? + frameBuilder, ImageErrorWidgetBuilder? errorBuilder, double? width, double? height, diff --git a/packages/core/test_resources/actual_data/assets_no_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_no_integrations.gen.dart index 62c45a616..a56272023 100644 --- a/packages/core/test_resources/actual_data/assets_no_integrations.gen.dart +++ b/packages/core/test_resources/actual_data/assets_no_integrations.gen.dart @@ -49,8 +49,13 @@ class $AssetsImagesGen { const AssetGenImage('assets/images/profile.png'); /// List of all assets - List get values => - [chip1, chip2, logo, profileJpg, profilePng]; + List get values => [ + chip1, + chip2, + logo, + profileJpg, + profilePng, + ]; } class $AssetsJsonGen { @@ -116,11 +121,7 @@ class Assets { } class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }); + const AssetGenImage(this._assetName, {this.size, this.flavors = const {}}); final String _assetName; @@ -180,15 +181,8 @@ class AssetGenImage { ); } - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); + ImageProvider provider({AssetBundle? bundle, String? package}) { + return AssetImage(_assetName, bundle: bundle, package: package); } String get path => _assetName; diff --git a/packages/core/test_resources/actual_data/build_assets.gen.dart b/packages/core/test_resources/actual_data/build_assets.gen.dart index ca3b59954..7dfe4d133 100644 --- a/packages/core/test_resources/actual_data/build_assets.gen.dart +++ b/packages/core/test_resources/actual_data/build_assets.gen.dart @@ -158,11 +158,7 @@ class Assets { } class AssetGenImage { - const AssetGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }); + const AssetGenImage(this._assetName, {this.size, this.flavors = const {}}); final String _assetName; @@ -222,15 +218,8 @@ class AssetGenImage { ); } - ImageProvider provider({ - AssetBundle? bundle, - String? package, - }) { - return AssetImage( - _assetName, - bundle: bundle, - package: package, - ); + ImageProvider provider({AssetBundle? bundle, String? package}) { + return AssetImage(_assetName, bundle: bundle, package: package); } String get path => _assetName; @@ -239,17 +228,11 @@ class AssetGenImage { } class SvgGenImage { - const SvgGenImage( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = false; - - const SvgGenImage.vec( - this._assetName, { - this.size, - this.flavors = const {}, - }) : _isVecFormat = true; + const SvgGenImage(this._assetName, {this.size, this.flavors = const {}}) + : _isVecFormat = false; + + const SvgGenImage.vec(this._assetName, {this.size, this.flavors = const {}}) + : _isVecFormat = true; final String _assetName; final Size? size; @@ -278,18 +261,11 @@ class SvgGenImage { }) { final _svg.BytesLoader loader; if (_isVecFormat) { - loader = _vg.AssetBytesLoader( - _assetName, - assetBundle: bundle, - packageName: package, - ); + loader = _vg.AssetBytesLoader(_assetName, + assetBundle: bundle, packageName: package); } else { - loader = _svg.SvgAssetLoader( - _assetName, - assetBundle: bundle, - packageName: package, - theme: theme, - ); + loader = _svg.SvgAssetLoader(_assetName, + assetBundle: bundle, packageName: package, theme: theme); } return _svg.SvgPicture( loader,