-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincrement-with-text-and-number.dart
More file actions
60 lines (51 loc) · 1.13 KB
/
increment-with-text-and-number.dart
File metadata and controls
60 lines (51 loc) · 1.13 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
49
50
51
52
53
54
55
56
57
58
59
60
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int number1 = 0;
final myController = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Button Test with Text Input'),
),
body: Column(
children: [
pressMe1(),
TextField(controller: myController),
displayNumberAndText(),
],
),
),
);
}
void increment1() {
setState(() {
number1++;
});
}
Widget displayNumberAndText() {
return Container(
margin: EdgeInsets.all(20),
child: Text("$number1 ${myController.text}"),
);
}
Widget pressMe1() {
return Container(
margin: EdgeInsets.all(20),
child: FlatButton(
child: Text('Increase Number A'),
color: Colors.blue,
textColor: Colors.white,
onPressed: increment1,
),
);
}
}