Flutter 4.1 - Những widget quan trọng
| MaterialApp / CupertinoApp |
|
| Scaffold / CupertinoPageScaffold |
Container
Row / Column
Flexible / Expanded
|
Stack
- Used to position items on top of each other (along the Z axis)
- Widgets can overlap
- You can position items in absolute space (i.e. in a coordinate space) via the Positioned() widget
Card
- A container with some default styling (shadow, background color, rounded corners)
- Can take one child (can be anything)
- Typically used to output a single piece / group of information
ListView / GridView
- Used to output lists (or grids) of items
- Like a Column() but scrollable (Column is not)
- Can be laid out vertically (default) and horizontally
- Use ListView.builder() to get optimized item rendering for very long lists
ListTile
- A pre-styled container / Row() that allows you to achieve a typical “list-item look”
- Offers various slots for widgets (e.g. at the beginning, a title, at the end)
- Not a must-use but can be handy for a default list-item lookDetails
Text
- A widget that simply outputs some text on the screen
- Text can be styled (font family, font weight, font size etc)
- Text behavior can be controlled (e.g. clipping if it’s too long)
Image
- Used to render an image on the screen
- Supports different sources (included in app, web image, …)
- Can be configured to size itself in different ways into a wrapping container
Icon
- Renders an Icon onto the screen
- Flutter ships with many default Material (Android) and iOS icons which you can use
- There also is an IconButton() widget in case you need a button with an icon
TextField
- Renders an editable text field where the user can enter (type) information
- Many, many configuration options (e.g. autocorrection, error messages, labels, styles)
- Supports different kinds of keyboard (email, number, normal text, …)
RaisedButton / FlatButton /
IconButton
- Differently styled buttons that handle user taps
- A custom function that should execute upon a tap can (and has to be) provided
- Can be styled / customized
GestureDetector / InkWell
- GestureDetector allows you to wrap ANY widget with touch listeners (e.g. double tap, long tap)
- InkWell does the same but adds a visual ripple effect upon touches (effect can be configured)
- You can build your own buttons / touchable widgets with these widgets





Nhận xét
Đăng nhận xét