WidgetsFlutterBinding khởi tạo Flutter engine.
- Dùng
WidgetsFlutterBinding.ensureInitialized()trước khi chạy app để khởi tạo plugin/service trướcrunApp(). - Trường hợp dùng phổ biến: setup
GetIttrước khi app khởi động, khởi tạo code native, cấu hình logging. - Không có nó, một số khởi tạo bất đồng bộ sẽ thất bại vì binding chưa sẵn sàng.
- Luôn gọi trong
main()nếu có setup trước app.
WidgetsFlutterBinding.ensureInitialized() initializes the Flutter engine before runApp().
- Use it when you need to initialize plugins, native code, or services before the app starts.
- Without it, some async initialization fails because the binding isn't ready yet.