Flutter 2.7 - Stateless to Stateful

 

StatelessWidget



StatefulWidget


Giải thích code ^^ từ Stateless sang Statefull:

1. Tạo class MyAppState extends State<MyApp> : chú ý coding conventions.
2. Override createState, return về class mới tạo.
3. setState(){} : báo hiệu dữ liệu thay đổi.
Note: dấu _ trước các function,class, variable tương đương với private. Ko có => public

Nhận xét

Bài đăng phổ biến từ blog này

Flutter 4.5 - Custom theme, font, image

Flutter 1.2 - Flutter Architecture

Flutter 2.5 - First App | Building a Widget Tree