-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.dart
More file actions
50 lines (42 loc) · 1.16 KB
/
main.dart
File metadata and controls
50 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp>{
Color backgroundcolor =Colors.white38;
// final List<String> _items = [];
// void addItem(){
// setState(() {
// int index = _items.length + 1;
// _items.add('Item $index');
// });
// }
void changeBackgroundColor() {
setState(() {
backgroundcolor = Color ((Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
// List colors = [Colors.purple,Colors.orange,Colors.amber];
// Random random = new Random();
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: GestureDetector(
onTap: changeBackgroundColor,
child: Container(
color: backgroundcolor,
child: const Center(
child: Text('Hello there',style: TextStyle(fontSize: 26),
),
),
),
),
));
}
}