Skip to content

🔥 Removes Flare integration #618

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 17 commits into from
Dec 15, 2024
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
21 changes: 7 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,22 @@ jobs:
if: startsWith(matrix.os, 'windows')
run: echo "%LOCALAPPDATA%\Pub\Cache\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Get dependencies for macos and ubuntu
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
- name: Get dependencies
run: |
dart pub global activate melos
melos bootstrap

- name: Get dependencies for Windows
if: startsWith(matrix.os, 'windows')
run: |
dart pub global activate melos
# FIXME: CI randomly fail
melos exec -c 1 -- flutter pub get
melos bootstrap
- name: Run tests for Dart packages
if: startsWith(matrix.os, 'ubuntu')
run: melos test:dart --no-select

- name: Run tests for our dart project.
- name: Run tests for Flutter packages
if: startsWith(matrix.os, 'ubuntu')
run: |
melos test
run: melos test:flutter --no-select

- name: Run coverage
if: startsWith(matrix.os, 'ubuntu')
run: |
melos coverage
run: melos coverage

- uses: codecov/codecov-action@v5
with:
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ flutter_gen:
# Optional
integrations:
flutter_svg: true
flare_flutter: true
rive: true
lottie: true

Expand Down Expand Up @@ -398,11 +397,9 @@ Widget build(BuildContext context) {
| Packages | File extension | Setting | Usage |
|---------------------------------------------------------|----------------|-----------------------|-------------------------------------------|
| [flutter_svg](https://pub.dev/packages/flutter_svg) | .svg | `flutter_svg: true` | Assets.images.icons.paint.**svg()** |
| [flare_flutter](https://pub.dev/packages/flare_flutter) | .flr | `flare_flutter: true` | Assets.flare.penguin.**flare()** |
| [rive](https://pub.dev/packages/rive) | .flr | `rive: true` | Assets.rive.vehicles.**rive()** |
| [rive](https://pub.dev/packages/rive) | .riv | `rive: true` | Assets.rive.vehicles.**rive()** |
| [lottie](https://pub.dev/packages/lottie) | .json, .zip | `lottie: true` | Assets.lottie.hamburgerArrow.**lottie()** |


In other cases, the asset is generated as String class.

```dart
Expand Down
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ analyzer:
- '**.g.dart'
- 'test_resources/**'
errors:
deprecated_member_use_from_same_package: ignore
unnecessary_import: error
unawaited_futures: error

Expand Down
53 changes: 2 additions & 51 deletions examples/example/lib/gen/assets.gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// ignore_for_file: type=lint
// ignore_for_file: directives_ordering,unnecessary_import,implicit_dynamic_list_literal,deprecated_member_use

import 'package:flare_flutter/flare_actor.dart' as _flare_actor;
import 'package:flare_flutter/flare_controller.dart' as _flare_controller;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart' as _svg;
Expand All @@ -20,10 +18,10 @@ class $AssetsFlareGen {
const $AssetsFlareGen();

/// File path: assets/flare/Penguin.flr
FlareGenImage get penguin => const FlareGenImage('assets/flare/Penguin.flr');
String get penguin => 'assets/flare/Penguin.flr';

/// List of all assets
List<FlareGenImage> get values => [penguin];
List<String> get values => [penguin];
}

class $AssetsImagesGen {
Expand Down Expand Up @@ -386,53 +384,6 @@ class SvgGenImage {
String get keyName => _assetName;
}

class FlareGenImage {
const FlareGenImage(
this._assetName, {
this.flavors = const {},
});

final String _assetName;
final Set<String> flavors;

_flare_actor.FlareActor flare({
String? boundsNode,
String? animation,
BoxFit fit = BoxFit.contain,
Alignment alignment = Alignment.center,
bool isPaused = false,
bool snapToEnd = false,
_flare_controller.FlareController? controller,
_flare_actor.FlareCompletedCallback? callback,
Color? color,
bool shouldClip = true,
bool sizeFromArtboard = false,
String? artboard,
bool antialias = true,
}) {
return _flare_actor.FlareActor(
_assetName,
boundsNode: boundsNode,
animation: animation,
fit: fit,
alignment: alignment,
isPaused: isPaused,
snapToEnd: snapToEnd,
controller: controller,
callback: callback,
color: color,
shouldClip: shouldClip,
sizeFromArtboard: sizeFromArtboard,
artboard: artboard,
antialias: antialias,
);
}

String get path => _assetName;

String get keyName => _assetName;
}

class RiveGenImage {
const RiveGenImage(
this._assetName, {
Expand Down
15 changes: 0 additions & 15 deletions examples/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ void main() async {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Auto generated image from FlutterGen.
SizedBox(
width: 200,
height: 200,
child: MyAssets.flare.penguin.flare(
animation: 'walk',
fit: BoxFit.contain,
),
),
SizedBox(
width: 200,
height: 200,
Expand Down Expand Up @@ -105,13 +97,6 @@ void main() async {
fit: BoxFit.contain,
),
),
SizedBox(
width: 200,
height: 200,
child: ResAssets.images.favorite.flare(
shouldClip: false,
),
),
SizedBox(
width: 200,
height: 200,
Expand Down
2 changes: 0 additions & 2 deletions examples/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
sdk: flutter

flutter_svg: ^2.0.0
flare_flutter: ^3.0.0
rive: ^0.11.0
lottie: ^2.0.0

Expand All @@ -31,7 +30,6 @@ flutter_gen:

integrations:
flutter_svg: true
flare_flutter: true
rive: true
lottie: true

Expand Down
54 changes: 1 addition & 53 deletions examples/example_resources/lib/gen/assets.gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// ignore_for_file: type=lint
// ignore_for_file: directives_ordering,unnecessary_import,implicit_dynamic_list_literal,deprecated_member_use

import 'package:flare_flutter/flare_actor.dart' as _flare_actor;
import 'package:flare_flutter/flare_controller.dart' as _flare_controller;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart' as _svg;
Expand All @@ -23,8 +21,7 @@ class $AssetsImagesGen {
SvgGenImage get dart => const SvgGenImage('assets/images/dart.svg');

/// File path: assets/images/favorite.flr
FlareGenImage get favorite =>
const FlareGenImage('assets/images/favorite.flr');
String get favorite => 'assets/images/favorite.flr';

/// File path: assets/images/flutter3.jpg
AssetGenImage get flutter3 =>
Expand Down Expand Up @@ -227,55 +224,6 @@ class SvgGenImage {
String get keyName => 'packages/example_resources/$_assetName';
}

class FlareGenImage {
const FlareGenImage(
this._assetName, {
this.flavors = const {},
});

final String _assetName;
final Set<String> flavors;

static const String package = 'example_resources';

_flare_actor.FlareActor flare({
String? boundsNode,
String? animation,
BoxFit fit = BoxFit.contain,
Alignment alignment = Alignment.center,
bool isPaused = false,
bool snapToEnd = false,
_flare_controller.FlareController? controller,
_flare_actor.FlareCompletedCallback? callback,
Color? color,
bool shouldClip = true,
bool sizeFromArtboard = false,
String? artboard,
bool antialias = true,
}) {
return _flare_actor.FlareActor(
'packages/example_resources/$_assetName',
boundsNode: boundsNode,
animation: animation,
fit: fit,
alignment: alignment,
isPaused: isPaused,
snapToEnd: snapToEnd,
controller: controller,
callback: callback,
color: color,
shouldClip: shouldClip,
sizeFromArtboard: sizeFromArtboard,
artboard: artboard,
antialias: antialias,
);
}

String get path => _assetName;

String get keyName => 'packages/example_resources/$_assetName';
}

class RiveGenImage {
const RiveGenImage(
this._assetName, {
Expand Down
2 changes: 0 additions & 2 deletions examples/example_resources/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
sdk: flutter

flutter_svg: ^2.0.0
flare_flutter: ^3.0.0
rive: ^0.11.0
lottie: ^2.0.0

Expand All @@ -25,7 +24,6 @@ flutter_gen:

integrations:
flutter_svg: true
flare_flutter: true
rive: true
lottie: true

Expand Down
6 changes: 4 additions & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@ scripts:
description: dart & flutter test

test:dart:
run: dart test
run: dart test --concurrency=1
exec:
concurrency: 1
failFast: true
packageFilters:
flutter: false
dependsOn: test
description: dart test

test:flutter:
run: flutter test
run: flutter test --concurrency=1
exec:
concurrency: 1
failFast: true
packageFilters:
flutter: true
Expand Down
1 change: 1 addition & 0 deletions packages/command/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/lib/gen/
19 changes: 11 additions & 8 deletions packages/command/bin/flutter_gen_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'dart:io';
import 'package:args/args.dart';
import 'package:flutter_gen_core/flutter_generator.dart';
import 'package:flutter_gen_core/utils/cast.dart';
import 'package:flutter_gen_core/utils/error.dart';
import 'package:flutter_gen_core/version.gen.dart';


void main(List<String> args) {
void main(List<String> args) async {
final parser = ArgParser();
parser.addOption(
'config',
Expand All @@ -19,7 +19,6 @@ void main(List<String> args) {
'build',
abbr: 'b',
help: 'Set the path of build.yaml.',
defaultsTo: 'build.yaml',
);

parser.addFlag(
Expand All @@ -43,7 +42,7 @@ void main(List<String> args) {
stdout.writeln(parser.usage);
return;
} else if (results.wasParsed('version')) {
stdout.writeln('FlutterGen v$packageVersion');
stdout.writeln('[FlutterGen] v$packageVersion');
return;
}
} on FormatException catch (e) {
Expand All @@ -58,11 +57,15 @@ void main(List<String> args) {
}
final pubspecFile = File(pubspecPath).absolute;

final buildPath = safeCast<String>(results['build']);
if (buildPath == null || buildPath.trim().isEmpty) {
final buildPath = safeCast<String>(results['build'])?.trim();
if (buildPath?.isEmpty ?? false) {
throw ArgumentError('Invalid value $buildPath', 'build');
}
final buildFile = File(buildPath).absolute;
final buildFile = buildPath == null ? null : File(buildPath).absolute;

FlutterGenerator(pubspecFile, buildFile: buildFile).build();
try {
await FlutterGenerator(pubspecFile, buildFile: buildFile).build();
} on InvalidSettingsException catch (e) {
stderr.write(e.message);
}
}
Loading
Loading