From reading https://api.flutter.dev/flutter/material/Scaffold-class.html and various examples online, I get the impression that the "best practice" layout hierarchy for Flutter is as follows:
MaterialApp
⮡ Scaffold
⮡ AnnotatedRegion (optional)
⮡ SafeArea (optional)
My question:
Considering performance (if any) and best practice, where should I put eg FutureBuilder
, OrientationBuilder
and MobX's Observer
if they happen to be global wrappers?
I usually put my global wrappers between MaterialApp and Scaffold, reason being that MaterialApp is your router, and if the app has authentication, I put that stream in front of global wrappers. So I find best practice to look like this:
MaterialApp (Theme and Route)
⮡ Router (Optional - something like Fluro Router)
⮡ AuthStream (Using StreamProvider - Checks whether user is logged in or not, if not returns to Login)
⮡ Wrapper (Holds my Future Builders)
⮡ Scaffold
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.