-
Notifications
You must be signed in to change notification settings - Fork 580
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
Add crossword
sample
#56
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.
LGTM with some random comments.
samples/crossword/lib/model.dart
Outdated
static int locationComparator(CrosswordWord a, CrosswordWord b) { | ||
final compareRows = a.location.y.compareTo(b.location.y); | ||
final compareColumns = a.location.x.compareTo(b.location.x); | ||
return switch (compareColumns) { 0 => compareRows, _ => compareColumns }; |
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] A little too fancy for my taste, but that's okay. I think this should have a trailing comma so that the cases are below each other.
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
/// An extension on [Duration] that adds a method to format the duration. | ||
extension DurationFormat on Duration { | ||
/// A human-readable string representation of the duration. | ||
/// This format is tuned for durations in the seconds to days range. | ||
String get formatted { | ||
final hours = inHours.remainder(24).toString().padLeft(2, '0'); | ||
final minutes = inMinutes.remainder(60).toString().padLeft(2, '0'); | ||
final seconds = inSeconds.remainder(60).toString().padLeft(2, '0'); | ||
return switch ((inDays, inHours, inMinutes, inSeconds)) { | ||
(0, 0, 0, _) => '${inSeconds}s', | ||
(0, 0, _, _) => '$inMinutes:$seconds', | ||
(0, _, _, _) => '$inHours:$minutes:$seconds', | ||
_ => '$inDays days, $hours:$minutes:$seconds', | ||
}; | ||
} | ||
} |
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 very nice and I'm probably going to steal this.
duration: Durations.extralong1, | ||
curve: Curves.easeInOut, | ||
color: explorationCell | ||
? Theme.of(context).colorScheme.primary |
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] Lots of Theme.of(context).colorScheme
. Could be extracted to a local variable at the top of the function: both for readability and (tiny) perf improvement.
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
.rebuild( | ||
(b) => b.where((b) => b.direction == Direction.across), | ||
) |
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.
Does this really need a rebuild step? Is there no where
on built lists? Or at least toList().where()
?
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 got into the habit of always rebuilding. To save the .toBuiltList()
call.
auto label is removed for flutter/games/56, due to - The status or check suite Test Flutter beta on windows-latest has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Fixes: flutter/flutter#149286
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-devrel channel on Discord.