-
Notifications
You must be signed in to change notification settings - Fork 247
[101] Complete #2
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
[101] Complete #2
Conversation
MDC-101/complete/lib/login.dart
Outdated
decoration: InputDecoration( | ||
border: const UnderlineInputBorder(), | ||
filled: true, | ||
labelText: "Username", |
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, do we care if we use single vs. double quotes in the same file? You use them both in this file.
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( |
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, formatting. If you're using IntelliJ there should be a Tools -> Autoformat with dartfmt you can use, and map that to a keyboard shortcut.
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 ran it! That's the way it did it.
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.
Looks like it may have a bug? Don't know. Fixed it tho.
MDC-101/complete/lib/login.dart
Outdated
], | ||
), | ||
), | ||
SizedBox(height: 121.0), |
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 thought Material was about having heights/font sizes etc. in multiples of 4? E.g this would be 120.0 and the SizedBox below would be 12.0 or 16.0? This might be a team-specific guideline so feel free to ignore.
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.
Good point. My mocks were 121 but no need to bring attention to it.
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.
Done.
MDC-101/complete/lib/main.dart
Outdated
|
||
import 'package:flutter/material.dart'; | ||
|
||
void main() => runApp(new ShrineApp()); |
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 think you can remove the new
? (probably not on the tip of tree of Flutter due to flutter/flutter#15590 but theoretically, you should be?)
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.
Done.
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.
Looks like a good start
MDC-101/complete/lib/login.dart
Outdated
padding: EdgeInsets.symmetric(horizontal: 24.0), | ||
children: <Widget>[ | ||
SizedBox(height: 80.0), | ||
Container( |
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.
This container isn't needed.
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
SizedBox(height: 120.0), | ||
TextField( | ||
decoration: InputDecoration( | ||
border: const UnderlineInputBorder(), |
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.
This is the default, you don't need to specify it.
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
child: Text('NEXT'), | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}) |
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.
Add a trailing comma and then put the closing paren under the class name (same as everywhere else):
RaisedButton(
child: Text('NEXT'),
onPressed: () {
Navigator.pop(context);
},
),
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( |
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.
There's an extra indent here
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.
That indent is coming from dartfmt. Think it could be somehow on purpose?
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 do not know, however it's inconsistent with style in the Flutter codebase.
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.
Looks like my dartfmt was out of date. updating and rerunning.
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
) | ||
], | ||
), | ||
)); |
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.
It looks like things didn't fit, so you ended up with a '))' line, because there's an extra indent at the top?
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.
Done.
MDC-101/complete/lib/login.dart
Outdated
child: ListView( | ||
padding: EdgeInsets.symmetric(horizontal: 24.0), | ||
children: <Widget>[ | ||
SizedBox(height: 80.0), |
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.
Are these SizedBox instances being used to block out padding for the layout? If so, is that considered the correct way to do it, rather than wrapping the following Widget in Padding(padding: EdgeInsets.only(top:80.0))
?
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.
That's a good point. I find that this style of inserting space between list items, where the gaps are defined explicitly with sized boxes, is easier to read than when the padding is part of the items themselves.
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 do either! I don't know what would be more expected. From an iOS POV, I wouldn't expect any of this to work without a bunch more layout code so my instincts don't apply.
title: 'Shrine', | ||
home: HomePage(), | ||
initialRoute: '/login', | ||
onGenerateRoute: _getRoute, |
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.
Another comment that's more a question:
Is there a definite benefit to using onGenerateRoute here rather than supplying a map via the routes property? It may just be the examples I happen to be looking at right now, but that seems like a popular option:
I don't know that you can set the fullScreenDialog option that way, though, which may be a dealbreaker.
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.
+1, I was not even aware of onGenerateRoute
until now.
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.
It's all new to me! Need me to change it?
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.
Oh, actually, I used to have the routes map. But I couldn't get the pop to be a modal-style dismiss.
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.
Discussed offline, and this is definitely the better way to go. I'm now curious what other functionality you lose (if any) by using a straight up route table.
MDC-101/complete/lib/login.dart
Outdated
), | ||
), | ||
SizedBox(height: 32.0), | ||
Row( |
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.
FWIW, I'm using a ButtonBar here in my material example for the DevByte.
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.
Think I should? @HansMuller
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.
Done! I love it.
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.
LGTM with some nits
MDC-101/complete/lib/app.dart
Outdated
} | ||
|
||
Route<dynamic> _getRoute(RouteSettings settings) { | ||
if (settings.name == '/login') { |
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] Consider using the guard pattern here: if you can have a short (ideally one-line) if-else statement, use that instead of a longer if-else statement.
if (settings.name != '/login') return null;
return MaterialPageRoute<void>(
...
);
Of course, this depends. If you expect more routes, then the guard pattern would be silly.
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.
Done!
title: 'Shrine', | ||
home: HomePage(), | ||
initialRoute: '/login', | ||
onGenerateRoute: _getRoute, |
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.
+1, I was not even aware of onGenerateRoute
until now.
MDC-101/complete/lib/home.dart
Outdated
@@ -0,0 +1,20 @@ | |||
import 'package:flutter/material.dart'; | |||
|
|||
class HomePage extends StatefulWidget { |
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.
You don't need stateful here, but I assume you know this.
There's a cool IDE feature in both IntelliJ and VS Code that lets you convert StatelessWidget to StatefulWidget with two keystrokes. You might want to teach this in the next step, because it's super helpful.
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.
It was because later I need it. But instead I'll take that moment to teach them, yeah.
|
||
import 'app.dart'; | ||
|
||
void main() => runApp(ShrineApp()); |
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.
Just FYI: optional new/const might not make it for I/O. That's a worst case scenario, but after the recent snafu, it's a lot more probable than before.
MDC-101/complete/pubspec.yaml
Outdated
@@ -0,0 +1,21 @@ | |||
name: mdc_101_complete | |||
description: Learn the basics of using Material Components by building a simple app with core components. |
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.
You can stay inside width limit with
description: >
Learn the basics of using Material Components by building a simple app
with core components.
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.
Done.
MDC-101/complete/pubspec.yaml
Outdated
sdk: flutter | ||
|
||
|
||
# The following section is specific to Flutter. |
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.
Since you already got rid of all the other comments, I think you can get rid of this one as well. (And the preceding blank line.)
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.
Done.
title: 'Shrine', | ||
home: HomePage(), | ||
initialRoute: '/login', | ||
onGenerateRoute: _getRoute, |
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.
Discussed offline, and this is definitely the better way to go. I'm now curious what other functionality you lose (if any) by using a straight up route table.
Magic numbers and strings are for educational simplicity.