Skip to content

Commit

Permalink
📝 Fix examples for null-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
lig committed Dec 3, 2020
1 parent 8936523 commit aa108e5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
3 changes: 0 additions & 3 deletions doc/examples/debug/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class AndroidComponent extends SpriteComponent with Resizable {
@override
void update(double dt) {
super.update(dt);
if (gameSize == null) {
return;
}

x += xDirection * SPEED * dt;

Expand Down
4 changes: 2 additions & 2 deletions doc/examples/gestures/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MyGame extends Game
final _greenPaint = Paint()..color = const Color(0xFF00FF00);
final _redPaint = Paint()..color = const Color(0xFFFF0000);

Paint? _paint;
late Paint _paint;

Rect _rect = const Rect.fromLTWH(50, 50, 50, 50);

Expand Down Expand Up @@ -49,6 +49,6 @@ class MyGame extends Game

@override
void render(Canvas canvas) {
if (_paint != null) canvas.drawRect(_rect, _paint!);
canvas.drawRect(_rect, _paint);
}
}
4 changes: 2 additions & 2 deletions doc/examples/particles/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class MyGame extends BaseGame {
generator: (i) => MovingParticle(
curve: Interval(rnd.nextDouble() * .1, rnd.nextDouble() * .8 + .1),
to: randomCellOffset() * .5,
child: reusablePatricle,
child: reusablePatricle!,
),
);
}
Expand Down Expand Up @@ -324,7 +324,7 @@ class MyGame extends BaseGame {
(i % perLine) * colWidth - halfCellSize!.x + imageSize,
(i ~/ perLine) * rowHeight - halfCellSize!.y + imageSize,
),
child: reusableImageParticle),
child: reusableImageParticle!),
);
}

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/widgets/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Anchor? parseAnchor(String? name) {
void main() async {
WidgetsFlutterBinding.ensureInitialized();

final dashbook = Dashbook();
final Dashbook dashbook = Dashbook();

final nineTileBoxImage = await Flame.images.load('nine_tile_box.png');
dashbook.storiesOf('NineTileBox').decorator(CenterDecorator()).add(
Expand Down
4 changes: 1 addition & 3 deletions lib/game/base_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ class BaseGame extends Game with FPSCounter {
}

// first time resize
if (size != null) {
c.onGameResize(size);
}
c.onGameResize(size);
}

/// Prepares and registers a component to be added on the next game tick
Expand Down

0 comments on commit aa108e5

Please sign in to comment.