diff --git a/doc/tutorials/platformer/app/lib/ember_quest.dart b/doc/tutorials/platformer/app/lib/ember_quest.dart index 057eea17ad2..a2a1cf15204 100644 --- a/doc/tutorials/platformer/app/lib/ember_quest.dart +++ b/doc/tutorials/platformer/app/lib/ember_quest.dart @@ -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( 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, ), diff --git a/packages/flame/lib/src/widgets/base_future_builder.dart b/packages/flame/lib/src/widgets/base_future_builder.dart index 336f519116a..50a1612c2b6 100644 --- a/packages/flame/lib/src/widgets/base_future_builder.dart +++ b/packages/flame/lib/src/widgets/base_future_builder.dart @@ -28,12 +28,13 @@ class BaseFutureBuilder 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(); } }, diff --git a/packages/flame/test/components/scroll_text_box_component_test.dart b/packages/flame/test/components/scroll_text_box_component_test.dart index ef83aec181a..00b0f6e4cfb 100644 --- a/packages/flame/test/components/scroll_text_box_component_test.dart +++ b/packages/flame/test/components/scroll_text_box_component_test.dart @@ -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); }, ); @@ -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); }, ); diff --git a/packages/flame/test/components/text_box_component_test.dart b/packages/flame/test/components/text_box_component_test.dart index db323d953fe..cea77c9445b 100644 --- a/packages/flame/test/components/text_box_component_test.dart +++ b/packages/flame/test/components/text_box_component_test.dart @@ -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); }, ); diff --git a/packages/flame/test/effects/controllers/effect_controller_test.dart b/packages/flame/test/effects/controllers/effect_controller_test.dart index 227b072d416..8e36d659acc 100644 --- a/packages/flame/test/effects/controllers/effect_controller_test.dart +++ b/packages/flame/test/effects/controllers/effect_controller_test.dart @@ -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, ); diff --git a/packages/flame/test/extensions/canvas_test.dart b/packages/flame/test/extensions/canvas_test.dart index 93d04b14383..ed9edf93ea5 100644 --- a/packages/flame/test/extensions/canvas_test.dart +++ b/packages/flame/test/extensions/canvas_test.dart @@ -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); @@ -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); diff --git a/packages/flame_bloc/pubspec.yaml b/packages/flame_bloc/pubspec.yaml index 23c42c8293e..59caae07181 100644 --- a/packages/flame_bloc/pubspec.yaml +++ b/packages/flame_bloc/pubspec.yaml @@ -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 diff --git a/packages/flame_lint/lib/analysis_options.yaml b/packages/flame_lint/lib/analysis_options.yaml index 5d86cb3ac20..94ac8fdcfa2 100644 --- a/packages/flame_lint/lib/analysis_options.yaml +++ b/packages/flame_lint/lib/analysis_options.yaml @@ -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" diff --git a/packages/flame_lint/pubspec.yaml b/packages/flame_lint/pubspec.yaml index 6daedd0af30..9db084d382f 100644 --- a/packages/flame_lint/pubspec.yaml +++ b/packages/flame_lint/pubspec.yaml @@ -10,5 +10,8 @@ funding: environment: sdk: ">=3.0.0 <4.0.0" +dependencies: + lints: ^3.0.0 + dev_dependencies: dartdoc: ^6.3.0