Search code examples
flutterdartflutter-layout

What is the difference between Scaffold and Container in Flutter?


I know both Scaffold and Container are parent widgets in Flutter, but when should I use a Scaffold and when should I use a Container to layout my child widget?


Solution

  • Scaffold and container serve different purposes for layout and design.

    Scaffold

    • Implements the basic material design visual layout structure.
    • This class provides APIs for showing drawers, snack bars, and bottom sheets.

    Link - Scaffold

    Container

    • A convenience widget that combines common painting, positioning, and sizing widgets.
    • It basically contains different widget into one widget over which you can give padding , size , position etc.

    Link -Container

    Conclusion

    You need Scaffold widget as main parent of your page where you use container for smaller widget into page to give them different properties like size, border, padding, margin etc.