Skip to content

Commit

Permalink
Refactor (#282)
Browse files Browse the repository at this point in the history
* refactor: move exluce property to asset scope

* chore: upgrade sdk for development
  • Loading branch information
wasabeef authored Aug 22, 2022
1 parent 2167b0d commit 2fa5eb0
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dart.flutterSdkPath": "~/.asdf/installs/flutter/3.0.1-stable",
"dart.sdkPath": "~/.asdf/installs/dart/2.17.1/dart-sdk"
"dart.flutterSdkPath": "~/.asdf/installs/flutter/3.0.5-stable",
"dart.sdkPath": "~/.asdf/installs/dart/2.17.6/dart-sdk"
}
17 changes: 0 additions & 17 deletions example/lib/gen/assets.gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import 'package:flare_flutter/flare_actor.dart';
import 'package:flare_flutter/flare_controller.dart';
import 'package:rive/rive.dart';

class $PicturesGen {
const $PicturesGen();

/// File path: pictures/chip5.jpg
AssetGenImage get chip5 => const AssetGenImage('pictures/chip5.jpg');
}

class $AssetsFlareGen {
const $AssetsFlareGen();

Expand All @@ -37,7 +30,6 @@ class $AssetsImagesGen {
/// File path: assets/images/chip2.jpg
AssetGenImage get chip2 => const AssetGenImage('assets/images/chip2.jpg');

$AssetsImagesChip3Gen get chip3 => const $AssetsImagesChip3Gen();
$AssetsImagesChip4Gen get chip4 => const $AssetsImagesChip4Gen();
$AssetsImagesIconsGen get icons => const $AssetsImagesIconsGen();

Expand Down Expand Up @@ -87,14 +79,6 @@ class $AssetsUnknownGen {
String get unknownMimeType => 'assets/unknown/unknown_mime_type.bk';
}

class $AssetsImagesChip3Gen {
const $AssetsImagesChip3Gen();

/// File path: assets/images/chip3/chip3.jpg
AssetGenImage get chip3 =>
const AssetGenImage('assets/images/chip3/chip3.jpg');
}

class $AssetsImagesChip4Gen {
const $AssetsImagesChip4Gen();

Expand Down Expand Up @@ -130,7 +114,6 @@ class Assets {
static const $AssetsMovieGen movie = $AssetsMovieGen();
static const $AssetsRiveGen rive = $AssetsRiveGen();
static const $AssetsUnknownGen unknown = $AssetsUnknownGen();
static const $PicturesGen pictures = $PicturesGen();
}

class AssetGenImage {
Expand Down
12 changes: 6 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ void main() async {
width: 120,
height: 120,
),
Assets.pictures.chip5.image(
key: const Key("chip5"),
width: 120,
height: 120,
fit: BoxFit.scaleDown,
),
// Assets.pictures.chip5.image(
// key: const Key("chip5"),
// width: 120,
// height: 120,
// fit: BoxFit.scaleDown,
// ),
const Text(
'Hi there, I\'m FlutterGen',
style: TextStyle(
Expand Down
6 changes: 5 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 1.0.0+2

environment:
sdk: ">=2.16.0 <3.0.0"
flutter: ">=2.10.4"
flutter: ">=3.0.0"

dependencies:
flutter:
Expand Down Expand Up @@ -131,6 +131,10 @@ flutter_gen:

# Assets.images.chip (default style)
# style: dot-delimiter
exclude:
- assets/images/chip3/chip3.jpg
- pictures/chip5.jpg
- assets/flare/

fonts:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion example_resources/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 1.0.0+2

environment:
sdk: ">=2.16.0 <3.0.0"
flutter: ">=2.10.4"
flutter: ">=3.0.0"

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion packages/core/lib/generators/assets_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AssetsGenConfig {
config.pubspec.packageName,
config.pubspec.flutterGen,
config.pubspec.flutter.assets,
config.pubspec.flutterGen.exclude
config.pubspec.flutterGen.assets.exclude
.map((pattern) => Glob(pattern))
.toList(),
);
Expand Down
3 changes: 1 addition & 2 deletions packages/core/lib/settings/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ flutter_gen:
enabled: true
package_parameter_enabled: false
style: dot-delimiter
exclude: []
fonts:
enabled: true
Expand All @@ -55,8 +56,6 @@ flutter_gen:
enabled: true
inputs: []
exclude: []
flutter:
assets: []
fonts: []
Expand Down
8 changes: 4 additions & 4 deletions packages/core/lib/settings/pubspec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class FlutterGen {
required this.fonts,
required this.integrations,
required this.colors,
required this.exclude,
});

@JsonKey(name: 'output', required: true)
Expand All @@ -79,9 +78,6 @@ class FlutterGen {
@JsonKey(name: 'colors', required: true)
final FlutterGenColors colors;

@JsonKey(name: 'exclude', required: true)
final List<String> exclude;

factory FlutterGen.fromJson(Map json) => _$FlutterGenFromJson(json);
}

Expand Down Expand Up @@ -109,6 +105,7 @@ class FlutterGenAssets {
required this.enabled,
required this.packageParameterEnabled,
required this.style,
required this.exclude,
}) {
if (style != dotDelimiterStyle &&
style != snakeCaseStyle &&
Expand All @@ -126,6 +123,9 @@ class FlutterGenAssets {
@JsonKey(name: 'style', required: true)
final String style;

@JsonKey(name: 'exclude', required: true)
final List<String> exclude;

bool get isDotDelimiterStyle => style == dotDelimiterStyle;

bool get isSnakeCaseStyle => style == snakeCaseStyle;
Expand Down
14 changes: 9 additions & 5 deletions packages/core/lib/settings/pubspec.g.dart

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.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ flutter_gen:
integrations:
flutter_svg: true

exclude:
- assets/images/chip3/*.jpg
- assets/images/*.png
- assets/**/icons/*
assets:
exclude:
- assets/images/chip3/*.jpg
- assets/images/*.png
- assets/**/icons/*

flutter:
uses-material-design: true
Expand Down

0 comments on commit 2fa5eb0

Please sign in to comment.