-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathFlutterSetup.txt
More file actions
37 lines (27 loc) · 1.3 KB
/
FlutterSetup.txt
File metadata and controls
37 lines (27 loc) · 1.3 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
Add the layout widget to the page
Simply this process
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter layout demo',
home: Scaffold(
appBar: AppBar(
title: Text('Flutter layout demo'),
),
body: Center(
child: Text('Hello World'),
),
),
);
}
}
What is Stateless and Stateful means?
A widget is either stateful or stateless.
If a widget can change—when a user interacts with it, for example—it’s stateful.
A stateless widget never changes. Icon, IconButton, and Text are examples of stateless widgets. Stateless widgets subclass StatelessWidget.
A stateful widget is dynamic:
for example, it can change its appearance in response to events triggered by user interactions or when it receives data.
Checkbox, Radio, Slider, InkWell, Form, and TextField are examples of stateful widgets.
Stateful widgets subclass StatefulWidget.
A widget’s state is stored in a State object, separating the widget’s state from its appearance. The state consists of values that can change, like a slider’s current value or whether a checkbox is checked. When the widget’s state changes, the state object calls setState(), telling the framework to redraw the widget.