-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_number_generator.dart
56 lines (47 loc) · 1.16 KB
/
random_number_generator.dart
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
49
50
51
52
53
54
55
56
//first file
import "package:flutter/material.dart";
import './first_screen.dart';
void main() {
runApp(MyFlutterApp());
}
class MyFlutterApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "My Flutter App",
home: Scaffold(
appBar: AppBar(
title:
Center(child: Text("My first App Screen",)),
),
body: FirstScreen()
)
);
}
}
//second file
import 'dart:math';
import 'package:flutter/material.dart';
class FirstScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
color: Colors.lightBlueAccent,
child: Center(
child: Text( generateluckynumber(),
// child: Text("Your lucky number is ${generateluckynumber()}",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
color: Colors.white,
),
),
),
);
}
}
String generateluckynumber(){
var random=Random();
return "Hello Flutter\n Your lucky number is ${random.nextInt(20)}";
}