mirrored_repositories/Flutter-Apps/dice_roll
import 'package:flutter/material.dart';
import 'dart:math';

final randomizer = Random();

class DiceRoller extends StatefulWidget {
  const DiceRoller({super.key});

  @override
  State<DiceRoller> createState() {
    return _DiceRollerState();
  }
}

class _DiceRollerState extends State<DiceRoller> {
  var clickDice = 3;
  void rollDice() {
    setState(() {
      clickDice = randomizer.nextInt(6) + 1;
    });
  }

  @override
  Widget build(context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Image.asset(
          'assets/images/dice-$clickDice.png',
          width: 200,
        ),
        ElevatedButton(
          onPressed: rollDice,
          style: ElevatedButton.styleFrom(
              foregroundColor: Colors.black,
              backgroundColor: Colors.white,
              elevation: 5.0,
              textStyle: const TextStyle(fontSize: 15.0),
              padding: const EdgeInsets.only(top: 5, bottom: 5)),
          child: const Text('Roll'),
        )
      ],
    );
  }
}
