Creating the grid

Let's create a new file for the game: we can call this pong.dart. This time, we'll need to create a Stateful widget, as there will be several values that will change during this class life cycle:

  1. Using the stful shortcut, let's create a new stateful widget called Pong:
import 'package:flutter/material.dart';import './ball.dart';import './bat.dart';class Pong extends StatefulWidget {  @override  _PongState createState() => _PongState();}class _PongState extends State<Pong> {  @override  Widget build(BuildContext context) {    return Container(); }}
  1. Instead of returning a Container, let's return a LayoutBuilder. This is a useful widget when you want to measure the space available in the context, including the parent constraints. ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.