import 'dart:math';
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: BackgroundChangerPage(),
      debugShowCheckedModeBanner: false,
    ),
  );
}

class BackgroundChangerPage extends StatefulWidget {

  @override
  _BackgroundChangerPageState createState() => _BackgroundChangerPageState();
}

class _BackgroundChangerPageState extends State<BackgroundChangerPage> {
  Color _color = Colors.transparent;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AnimatedContainer(
        color: _color,
        duration: Duration(seconds: 1),
        curve: Curves.fastOutSlowIn,
      ),
      floatingActionButton: FloatingActionButton.extended(
        label: Text('変更'),
        onPressed: () => changeColor(),
      ),
    );
  }

  void changeColor() {
    setState(() {
      final random = Random();
      _color = Color.fromRGBO(
        random.nextInt(256),
        random.nextInt(256),
        random.nextInt(256),
        1,
      );
    });
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.