Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone explain Navigator Class and Scaffold Class from Flutter?

The Flutter documentation is so vague. Can you guys explain what Google is vaguely saying:

Navigator Class

Many apps have a navigator near the top of their widget hierarchy in order to display their logical history using an Overlay with the most recently visited pages visually on top of the older pages.

  1. What does it mean "near the top [...] in order to display their logical history"?
  2. what does it mean by "logical history"?

Scaffold Class

Implements the basic material design visual layout structure.

  1. Why is the Scaffold class implementing material design? Isn't that the job of the MaterialApp class?
like image 792
Walter M Avatar asked Mar 06 '23 13:03

Walter M


1 Answers

Navigator

  1. "Near the top" means near the root of the widget hierarchy. For example if you use MaterialApp it contains a Navigator that allows to switch between different pages. Near the top means that adding a different route overlays all of the screen, not just a small part like a popup. There can be additional Navigators inside such a page for example to overlay smaller parts of the view.

  2. A bar with tabbar like functionality that allows to control which page the Navigator shows.

  3. You can use the back button to navigate to the previous page.

Scaffold

  1. MaterialApp is more about theme,
    Scaffold is more about structure of the screen. Where to position the AppBar, Drawer, content, ...

That they are different widgets makes it easier to replace one or the other with a custom implementation without the need to implement also the other in your custom implementation. Flutter is all about composability.

like image 77
Günter Zöchbauer Avatar answered Mar 10 '23 11:03

Günter Zöchbauer