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:
- 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(); }}
- 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. ...