Skip to content
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

feat: Expand flame_lint to respect required pub.dev checks #3139

Merged
merged 2 commits into from
Apr 28, 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
8 changes: 4 additions & 4 deletions doc/tutorials/platformer/app/lib/ember_quest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ class EmberQuestGame extends FlameGame
void loadGameSegments(int segmentIndex, double xPositionOffset) {
for (final block in segments[segmentIndex]) {
final component = switch (block.blockType) {
GroundBlock => GroundBlock(
GroundBlock _ => GroundBlock(
spydon marked this conversation as resolved.
Show resolved Hide resolved
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
PlatformBlock => PlatformBlock(
PlatformBlock _ => PlatformBlock(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
Star => Star(
Star _ => Star(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
WaterEnemy => WaterEnemy(
WaterEnemy _ => WaterEnemy(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
Expand Down
7 changes: 4 additions & 3 deletions packages/flame/lib/src/widgets/base_future_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ class BaseFutureBuilder<T> extends StatelessWidget {
case ConnectionState.active:
return loadingBuilder?.call(context) ?? const SizedBox();
case ConnectionState.done:
if (snapshot.hasData) {
return builder(context, snapshot.data!);
}
if (snapshot.hasError) {
return errorBuilder?.call(context) ?? const SizedBox();
}
final data = snapshot.data;
if (data != null) {
return builder(context, data);
}
return loadingBuilder?.call(context) ?? const SizedBox();
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ void main() {
(game) async {
final onComplete = MockOnCompleteCallback();

when(onComplete).thenReturn(null);
when(onComplete.call).thenReturn(null);

final component = ScrollTextBoxComponent(
size: Vector2(200, 100),
text: 'Short text',
onComplete: onComplete,
onComplete: onComplete.call,
);
await game.ensureAdd(component);

game.update(0.1);

verify(onComplete).called(1);
verify(onComplete.call).called(1);
},
);

Expand All @@ -30,19 +30,19 @@ void main() {
(game) async {
final onComplete = MockOnCompleteCallback();

when(onComplete).thenReturn(null);
when(onComplete.call).thenReturn(null);

final component = ScrollTextBoxComponent(
size: Vector2(200, 100),
text: '''Long text that will definitely require scrolling to be
fully visible in the given size of the ScrollTextBoxComponent.''',
onComplete: onComplete,
onComplete: onComplete.call,
);
await game.ensureAdd(component);

game.update(0.1);

verify(onComplete).called(1);
verify(onComplete.call).called(1);
},
);

Expand Down
6 changes: 3 additions & 3 deletions packages/flame/test/components/text_box_component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ void main() {
(game) async {
final onComplete = MockOnCompleteCallback();

when(onComplete).thenReturn(null);
when(onComplete.call).thenReturn(null);

final component = ScrollTextBoxComponent(
size: Vector2(200, 100),
text: 'Short text',
onComplete: onComplete,
onComplete: onComplete.call,
);
await game.ensureAdd(component);

game.update(0.1);

verify(onComplete).called(1);
verify(onComplete.call).called(1);
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ void main() {
final ec = EffectController(
duration: 1,
reverseDuration: 1,
onMax: mockOnMax,
onMin: mockOnMin,
onMax: mockOnMax.call,
onMin: mockOnMin.call,
infinite: true,
);

Expand Down
4 changes: 2 additions & 2 deletions packages/flame/test/extensions/canvas_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void main() {

final drawFunction = MocktailDrawFunction();
when(() => drawFunction.call(canvas)).thenReturn(null);
canvas.renderAt(Vector2(1, 1), drawFunction);
canvas.renderAt(Vector2(1, 1), drawFunction.call);
verify(canvas.save).called(1);
verify(() => canvas.translateVector(Vector2(1, 1))).called(1);
verify(() => drawFunction(canvas)).called(1);
Expand All @@ -54,7 +54,7 @@ void main() {

final drawFunction = MocktailDrawFunction();
when(() => drawFunction.call(canvas)).thenReturn(null);
canvas.renderRotated(0.5, Vector2(1, 1), drawFunction);
canvas.renderRotated(0.5, Vector2(1, 1), drawFunction.call);
verify(canvas.save).called(1);
verify(() => canvas.translateVector(Vector2(1, 1))).called(1);
verify(() => canvas.rotate(.5)).called(1);
Expand Down
1 change: 0 additions & 1 deletion packages/flame_bloc/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ dev_dependencies:
dartdoc: ^6.3.0
flame_lint: ^1.1.2
flame_test: ^1.16.1
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
mocktail: ^1.0.1
2 changes: 2 additions & 0 deletions packages/flame_lint/lib/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Source of linter options:
# https://dart-lang.github.io/linter/lints/options/options.html

include: package:lints/core.yaml

analyzer:
exclude:
- "**/*.g.dart"
Expand Down
3 changes: 3 additions & 0 deletions packages/flame_lint/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ funding:
environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
lints: ^3.0.0

dev_dependencies:
dartdoc: ^6.3.0
Loading