Creating the Single Dice screen

The first screen that we will create in the app is a screen that will allow the user to "throw" a single dice: no rules, no play. We'll just give the user a random value between 1 and 6. This will give us the opportunity to see a Flare animation in action in a Flutter screen. To do this, perform the following steps:

  1. Create a new file in the lib folder of the project, called single.dart.
  2. At the top of the file, import three files—the usual material.dart, our dice.dart file, and the library that will allow us to use Flare, which is flare_actor.dart, as follows:
import 'dice.dart';import 'package:flutter/material.dart';import 'package:flare_flutter/flare_actor.dart';
  1. Create a stateful widget, using the stful ...

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.