mirror of https://github.com/flutter/pinball.git
chore: refactoring to use flutter gen on the game (#73)
* chore: refactoring to use flutter gen on the game * fix: lint * Update lib/game/components/spaceship.dart Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> * fix: lint Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>pull/77/head
parent
c0f451b6f7
commit
c03cf6b2a2
@ -1 +1,4 @@
|
||||
include: package:very_good_analysis/analysis_options.2.4.0.yaml
|
||||
analyzer:
|
||||
exclude:
|
||||
- lib/**/*.gen.dart
|
||||
|
@ -1,16 +1,17 @@
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/gen/assets.gen.dart';
|
||||
|
||||
/// Add methods to help loading and caching game assets.
|
||||
extension PinballGameAssetsX on PinballGame {
|
||||
/// Pre load the initial assets of the game.
|
||||
Future<void> preLoadAssets() async {
|
||||
await Future.wait([
|
||||
images.load(Ball.spritePath),
|
||||
images.load(Flipper.spritePath),
|
||||
images.load(SpaceshipBridge.spritePath),
|
||||
images.load(SpaceshipBridgeTop.spritePath),
|
||||
images.load(SpaceshipWall.lowerWallPath),
|
||||
images.load(SpaceshipSaucer.upperWallPath),
|
||||
images.load(Assets.images.components.ball.path),
|
||||
images.load(Assets.images.components.flipper.path),
|
||||
images.load(Assets.images.components.spaceship.androidTop.path),
|
||||
images.load(Assets.images.components.spaceship.androidBottom.path),
|
||||
images.load(Assets.images.components.spaceship.lower.path),
|
||||
images.load(Assets.images.components.spaceship.upper.path),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
/// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
/// *****************************************************
|
||||
/// FlutterGen
|
||||
/// *****************************************************
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class $AssetsImagesGen {
|
||||
const $AssetsImagesGen();
|
||||
|
||||
$AssetsImagesComponentsGen get components =>
|
||||
const $AssetsImagesComponentsGen();
|
||||
}
|
||||
|
||||
class $AssetsImagesComponentsGen {
|
||||
const $AssetsImagesComponentsGen();
|
||||
|
||||
AssetGenImage get ball =>
|
||||
const AssetGenImage('assets/images/components/ball.png');
|
||||
AssetGenImage get flipper =>
|
||||
const AssetGenImage('assets/images/components/flipper.png');
|
||||
AssetGenImage get sauce =>
|
||||
const AssetGenImage('assets/images/components/sauce.png');
|
||||
$AssetsImagesComponentsSpaceshipGen get spaceship =>
|
||||
const $AssetsImagesComponentsSpaceshipGen();
|
||||
}
|
||||
|
||||
class $AssetsImagesComponentsSpaceshipGen {
|
||||
const $AssetsImagesComponentsSpaceshipGen();
|
||||
|
||||
AssetGenImage get androidBottom => const AssetGenImage(
|
||||
'assets/images/components/spaceship/android-bottom.png');
|
||||
AssetGenImage get androidTop =>
|
||||
const AssetGenImage('assets/images/components/spaceship/android-top.png');
|
||||
AssetGenImage get lower =>
|
||||
const AssetGenImage('assets/images/components/spaceship/lower.png');
|
||||
AssetGenImage get saucer =>
|
||||
const AssetGenImage('assets/images/components/spaceship/saucer.png');
|
||||
AssetGenImage get upper =>
|
||||
const AssetGenImage('assets/images/components/spaceship/upper.png');
|
||||
}
|
||||
|
||||
class Assets {
|
||||
Assets._();
|
||||
|
||||
static const $AssetsImagesGen images = $AssetsImagesGen();
|
||||
}
|
||||
|
||||
class AssetGenImage extends AssetImage {
|
||||
const AssetGenImage(String assetName) : super(assetName);
|
||||
|
||||
Image image({
|
||||
Key? key,
|
||||
ImageFrameBuilder? frameBuilder,
|
||||
ImageLoadingBuilder? loadingBuilder,
|
||||
ImageErrorWidgetBuilder? errorBuilder,
|
||||
String? semanticLabel,
|
||||
bool excludeFromSemantics = false,
|
||||
double? width,
|
||||
double? height,
|
||||
Color? color,
|
||||
BlendMode? colorBlendMode,
|
||||
BoxFit? fit,
|
||||
AlignmentGeometry alignment = Alignment.center,
|
||||
ImageRepeat repeat = ImageRepeat.noRepeat,
|
||||
Rect? centerSlice,
|
||||
bool matchTextDirection = false,
|
||||
bool gaplessPlayback = false,
|
||||
bool isAntiAlias = false,
|
||||
FilterQuality filterQuality = FilterQuality.low,
|
||||
}) {
|
||||
return Image(
|
||||
key: key,
|
||||
image: this,
|
||||
frameBuilder: frameBuilder,
|
||||
loadingBuilder: loadingBuilder,
|
||||
errorBuilder: errorBuilder,
|
||||
semanticLabel: semanticLabel,
|
||||
excludeFromSemantics: excludeFromSemantics,
|
||||
width: width,
|
||||
height: height,
|
||||
color: color,
|
||||
colorBlendMode: colorBlendMode,
|
||||
fit: fit,
|
||||
alignment: alignment,
|
||||
repeat: repeat,
|
||||
centerSlice: centerSlice,
|
||||
matchTextDirection: matchTextDirection,
|
||||
gaplessPlayback: gaplessPlayback,
|
||||
isAntiAlias: isAntiAlias,
|
||||
filterQuality: filterQuality,
|
||||
);
|
||||
}
|
||||
|
||||
String get path => assetName;
|
||||
}
|
Loading…
Reference in new issue