Skip to content
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
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flutter 3.27.1-stable
flutter 3.27.2-stable
12 changes: 6 additions & 6 deletions examples/example/lib/gen/assets.gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ class $AssetsLottieGen {

/// List of all assets
List<LottieGenImage> get values => [
xuiIZ9X1Rf,
alarmClockLottieV440,
geometricalAnimation,
hamburgerArrow,
spinningCarrousel,
];
xuiIZ9X1Rf,
alarmClockLottieV440,
geometricalAnimation,
hamburgerArrow,
spinningCarrousel,
];
}

class $AssetsMixGen {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/lib/flutter_generator.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(
Expand All @@ -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',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 10 additions & 6 deletions packages/core/test/assets_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});
});
});

Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/colors_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand All @@ -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',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/fonts_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down
9 changes: 4 additions & 5 deletions packages/core/test/gen_test_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> clearTestResults() async {}

Expand All @@ -35,7 +34,7 @@ Future<List<String>> 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',
);
Expand Down Expand Up @@ -79,7 +78,7 @@ Future<List<String>> runColorsGen(
final pubspecFile = File(pubspec);
final config = loadPubspecConfig(pubspecFile);
final formatter = DartFormatter(
languageVersion: currentDartVersion,
languageVersion: dartFormatterLanguageVersion,
pageWidth: config.pubspec.flutterGen.lineLength,
lineEnding: '\n',
);
Expand Down Expand Up @@ -123,7 +122,7 @@ Future<List<String>> runFontsGen(
final pubspecFile = File(pubspec);
final config = loadPubspecConfig(pubspecFile);
final formatter = DartFormatter(
languageVersion: currentDartVersion,
languageVersion: dartFormatterLanguageVersion,
pageWidth: config.pubspec.flutterGen.lineLength,
lineEnding: '\n',
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 12 additions & 36 deletions packages/core/test_resources/actual_data/build_assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading