-
Notifications
You must be signed in to change notification settings - Fork 7.7k
add web_dashboard sample #306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One real question and a bunch of nits. :)
@@ -0,0 +1,17 @@ | |||
# web_dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It'd be a good idea to add a couple sentences:
- Explain that this is an in-progress sample.
- Point out that it's just for the web, and shouldn't be built for Android/iOS/desktop.
You can also link from here to the README in /experimental, which will tell people about the need to use the master channel.
|
||
import 'src/adaptive_scaffold.dart'; | ||
|
||
/// The [Key] for the inner [Navigator] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Period at the end of the comments (here and below).
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
// Forward the initial route to the app shell. | ||
onGenerateInitialRoutes: (initialRoute){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space between the closing paren and the opening brace.
Related: Nothing in /experimental gets touched by CI, so formatting and analysis aren't checked automatically. I have an alias I use a lot that does both, in case it's of use to you:
alias fa='find . | grep "\.dart$" | xargs flutter format && flutter analyze'
// initial build phase. Right now this is being called in the wrong | ||
// order. (Refreshing the browser with the initial route set to | ||
// '/settings' invokes onGenerateRoute with '/' instead of | ||
// '/settings'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Closing paren.
}, | ||
), | ||
currentIndex: _currentIndex, | ||
destinations: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can this be a const list?
} | ||
|
||
/// A widget that adapts to the current display size, displaying a [Drawer], | ||
/// [NavigationRail], or [BottomAppBar]. Navigation destinations are defined in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: BottomNavigationBar rather than BottomAppBar?
return Scaffold( | ||
appBar: AppBar(title: widget.title,), | ||
body: Row( | ||
children: <Widget>[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitL: No type specifier necessary here.
var navState = _navigatorKey.currentState as NavigatorState; | ||
navState.pushNamed(_routeForIndex(idx)); | ||
}, | ||
floatingActionButton: FloatingActionButton( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can imagine wanting this button to have different effects based on which page is loaded into the navigator inside the AdaptiveScaffold. Is that something that would be supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the AdaptiveScaffold would cover that case. The user would be responsible for applying any effects (or hiding the FAB altogether) based on the currentIndex
.
closing in favor of #333, which moves this into an experiments/ directory |
This adds a responsive master-detail app with browser URL navigation. The app combines a new
AdaptiveScaffold
widget that switches between aDrawer
,NavigationRail
, andBottomAppBar
for navigation. The body of theScaffold
is aNavigator
that handles three routes usingonGenerateRoute
. The URL stays in sync with the routing in the app.Right now, there are two Navigators, the root Navigator and the child Navigator. The root Navigator forwards the initial route to the child using
onGenerateInitialRoutes
and passing theRouteSettings
. TheAppShell
widget's keeps the AdaptiveScaffold Navigator in sync.