Files
Luan Nico bac6c8a446 refactor: Add a few more rules to flame_lint, including use_key_in_widget_constructors (#1248)
This:

    Add new rule use_if_null_to_convert_nulls_to_bools to flame_lint (no violations)
    Add new rule use_key_in_widget_constructors (several violations)
    Fix violations
    Exclude generated files from flame_lint (we don't have any on this repo but when using on games often there are)

I believe this is not a breaking change because it just adds optional arguments to constructors, but if it is, we can reconsider this PR.
2021-12-19 11:07:42 +01:00

23 lines
549 B
Dart

import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flutter/material.dart';
class MyGameWidget extends StatelessWidget {
const MyGameWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return GameWidget(game: MyGame());
}
}
class MyGame extends FlameGame {
@override
Future<void> onLoad() async {
await super.onLoad();
final citySprite = await loadSprite('city.png');
await add(SpriteComponent(sprite: citySprite, size: Vector2.all(200)));
}
}