-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
refactor: Fix lint issues across the codebase #2672
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
include: package:flame_lint/analysis_options.yaml | ||
|
||
linter: | ||
rules: | ||
avoid_web_libraries_in_flutter: false | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,12 @@ class EmberPlayer extends SpriteAnimationComponent with TapCallbacks { | |
EmberPlayer({ | ||
required super.position, | ||
required super.size, | ||
void Function(EmberPlayer)? onTap, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name |
||
void Function(EmberPlayer player)? onTap, | ||
}) : _onTap = onTap, | ||
super(); | ||
|
||
Vector2 velocity = Vector2(0, 0); | ||
final void Function(EmberPlayer)? _onTap; | ||
final void Function(EmberPlayer player)? _onTap; | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import 'dart:math'; | ||
import 'dart:ui'; | ||
|
||
import 'package:flame/components.dart'; | ||
import 'package:flame/events.dart'; | ||
import 'package:flame/geometry.dart'; | ||
import 'package:flame/rendering.dart'; | ||
|
||
const tau = 2 * pi; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use flame's tau |
||
|
||
enum FlowerPaint { paintId1, paintId2, paintId3, paintId4, paintId5 } | ||
|
||
class Flower extends PositionComponent | ||
|
@@ -34,7 +32,7 @@ class Flower extends PositionComponent | |
} | ||
|
||
final List<Path> _paths = []; | ||
final void Function(Flower)? _onTap; | ||
final void Function(Flower flower)? _onTap; | ||
|
||
Path _makePath(double radius, int n, double sharpness, double f) { | ||
final radius2 = radius * f; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import 'dart:html'; // ignore: avoid_web_libraries_in_flutter | ||
import 'dart:html'; | ||
|
||
import 'package:doc_flame_examples/anchor.dart'; | ||
import 'package:doc_flame_examples/anchor_by_effect.dart'; | ||
|
@@ -44,37 +44,37 @@ void main() { | |
final routes = <String, Game Function()>{ | ||
'anchor_by_effect': AnchorByEffectGame.new, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. map keys alphabetical (was almost there) |
||
'anchor_to_effect': AnchorToEffectGame.new, | ||
'anchor': AnchorGame.new, | ||
'collision_detection': CollisionDetectionGame.new, | ||
'color_effect': ColorEffectExample.new, | ||
'decorator_blur': DecoratorBlurGame.new, | ||
'decorator_grayscale': DecoratorGrayscaleGame.new, | ||
'decorator_rotate3d': DecoratorRotate3DGame.new, | ||
'decorator_shadow3d': DecoratorShadowGame.new, | ||
'decorator_tint': DecoratorTintGame.new, | ||
'drag_events': DragEventsGame.new, | ||
'opacity_to_effect': OpacityToEffectGame.new, | ||
'opacity_effect_with_target': OpacityEffectWithTargetGame.new, | ||
'opacity_by_effect': OpacityByEffectGame.new, | ||
'glow_effect': GlowEffectExample.new, | ||
'move_along_path_effect': MoveAlongPathEffectGame.new, | ||
'move_by_effect': MoveByEffectGame.new, | ||
'move_to_effect': MoveToEffectGame.new, | ||
'opacity_by_effect': OpacityByEffectGame.new, | ||
'opacity_effect_with_target': OpacityEffectWithTargetGame.new, | ||
'opacity_to_effect': OpacityToEffectGame.new, | ||
'ray_cast': RayCastExample.new, | ||
'ray_trace': RayTraceExample.new, | ||
'remove_effect': RemoveEffectGame.new, | ||
'rive_example': RiveExampleGame.new, | ||
'rotate_by_effect': RotateByEffectGame.new, | ||
'rotate_to_effect': RotateToEffectGame.new, | ||
'router': RouterGame.new, | ||
'scale_by_effect': ScaleByEffectGame.new, | ||
'scale_to_effect': ScaleToEffectGame.new, | ||
'sequence_effect': SequenceEffectGame.new, | ||
'size_by_effect': SizeByEffectGame.new, | ||
'size_to_effect': SizeToEffectGame.new, | ||
'sequence_effect': SequenceEffectGame.new, | ||
'tap_events': TapEventsGame.new, | ||
'value_route': ValueRouteExample.new, | ||
'rive_example': RiveExampleGame.new, | ||
'ray_cast': RayCastExample.new, | ||
'ray_trace': RayTraceExample.new, | ||
'glow_effect': GlowEffectExample.new, | ||
'remove_effect': RemoveEffectGame.new, | ||
'color_effect': ColorEffectExample.new, | ||
'time_scale': TimeScaleGame.new, | ||
'anchor': AnchorGame.new, | ||
'value_route': ValueRouteExample.new, | ||
}; | ||
final game = routes[page]?.call(); | ||
if (game != null) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,11 @@ class RemoveEffectGame extends FlameGame with TapDetector { | |
|
||
@override | ||
void onTap() { | ||
if (!children.contains(ember)) { | ||
if (children.contains(ember)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
ember.add(effect); | ||
} else { | ||
effect.reset(); | ||
add(ember); | ||
} else { | ||
ember.add(effect); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import 'package:doc_flame_examples/flower.dart'; | ||
import 'package:flame/effects.dart'; | ||
import 'package:flame/game.dart'; | ||
import 'package:flame/geometry.dart'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just using existing declaration of tau |
||
|
||
class RotateByEffectGame extends FlameGame { | ||
bool reset = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,23 +33,17 @@ void main() { | |
|
||
final mockAsset = FakeAssetBundle({'logo.json': logoData}); | ||
|
||
LottieComposition? composition; | ||
|
||
final asset = Lottie.asset( | ||
'logo.json', | ||
bundle: mockAsset, | ||
onLoaded: (c) { | ||
composition = c; | ||
}, | ||
); | ||
|
||
composition = await loadLottie(asset); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. variable is set twice, trips https://dcm.dev/docs/rules/common/avoid-unnecessary-reassignment |
||
final composition = await loadLottie(asset); | ||
|
||
await game.ready(); | ||
|
||
expect(composition, isNotNull); | ||
expect( | ||
composition!.duration, | ||
composition.duration, | ||
const Duration(seconds: 5, milliseconds: 966), | ||
); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to put it here since it applies project-wise than in a single file