Files
Lukas Klingsbo 5c47d7f6d7 chore: analyze issues introduced from new dart version (#1196)
* Added Component.childrenFactory

* fix some of the lint warnings

* more lint warnings

* remove changelog entry

* more analyzer warnings

* one more warning

* one more warning

* remove more unused imports

* fix more warnings

* another warning

* one more warning

* a lot more warnings

* some more warnings

* fix warnings in flame_svg

* fix warnings in flame_bloc

* Remove OrderedSet override feature

* Remove testRandom change

* Remove unnecessary type checks

* Re-remove deprecated argument in random_test

Co-authored-by: Pasha Stetsenko <stpasha@google.com>
2021-12-09 15:40:43 +01:00

78 lines
1.7 KiB
Dart

import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
import 'package:flame_rive/flame_rive.dart';
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late final game = RiveExampleGame();
@override
Widget build(BuildContext context) {
return GameWidget(
game: game,
);
}
}
class RiveExampleGame extends FlameGame with HasTappables {
@override
Color backgroundColor() {
return const Color(0xFFFFFFFF);
}
@override
Future<void>? onLoad() async {
await super.onLoad();
final skillsArtboard =
await loadArtboard(RiveFile.asset('assets/skills.riv'));
add(SkillsAnimationComponent(skillsArtboard));
}
}
class SkillsAnimationComponent extends RiveComponent with Tappable {
SkillsAnimationComponent(Artboard artboard)
: super(
artboard: artboard,
size: Vector2.all(550),
);
SMIInput<double>? _levelInput;
@override
Future<void>? onLoad() {
final controller = StateMachineController.fromArtboard(
artboard,
"Designer's Test",
);
if (controller != null) {
artboard.addController(controller);
_levelInput = controller.findInput<double>('Level');
_levelInput?.value = 0;
}
return super.onLoad();
}
@override
bool onTapDown(TapDownInfo info) {
final levelInput = _levelInput;
if (levelInput == null) {
return false;
}
levelInput.value = (levelInput.value + 1) % 3;
return true;
}
}