GameWidget<T extends Game>.controlled constructor
const
GameWidget<T extends Game>.controlled ({
- required GameFactory<
T> gameFactory, - TextDirection? textDirection,
- GameLoadingWidgetBuilder? loadingBuilder,
- GameErrorWidgetBuilder? errorBuilder,
- WidgetBuilder? backgroundBuilder,
- Map<
String, OverlayWidgetBuilder< ? overlayBuilderMap,T> > - List<
String> ? initialActiveOverlays, - FocusNode? focusNode,
- bool autofocus = true,
- MouseCursor? mouseCursor,
- bool addRepaintBoundary = true,
- Key? key,
A GameWidget
which will create and own a Game
instance, using the
provided gameFactory.
This constructor can be useful when you want to put GameWidget
into
another widget, but would like to avoid the need to store the game's
instance yourself. For example:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(20),
child: GameWidget.controlled(
gameFactory: MyGame.new,
),
);
}
}
Implementation
const GameWidget.controlled({
required GameFactory<T> this.gameFactory,
this.textDirection,
this.loadingBuilder,
this.errorBuilder,
this.backgroundBuilder,
this.overlayBuilderMap,
this.initialActiveOverlays,
this.focusNode,
this.autofocus = true,
this.mouseCursor,
this.addRepaintBoundary = true,
super.key,
}) : game = null;