Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'dart:math';
- class App extends StatefulWidget {
- createState() {
- return Colore();
- }
- }
- class Colore extends State<App> {
- List colors = [Colors.red, Colors.green, Colors.yellow];
- Random random = new Random();
- int index = 0;
- void changeIndex() {
- setState(() => index = random.nextInt(3));
- }
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- appBar: AppBar(
- backgroundColor: Color(Colors.orange),
- title: Text('DisColor'),
- ),
- floatingActionButton: FloatingActionButton(
- child: Icon(Icons.explore),
- onPressed: () {
- changeIndex();
- },
- backgroundColor: Color(Colors.amber),),
- body: Container(
- color: colors[index],
- ),
- ),
- );
- }
- }
- void main() {
- runApp(App());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement