Skip to content

Conversation

Alabhya268
Copy link
Contributor

sample side - Closes #570
Cart

Let me know if anything needs to be changed.

Copy link
Contributor

@filiph filiph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Thanks.

I have some comments but conceptually LGTM.

In general, we don't want to add more functionality than what is absolutely needed to understand the concept being explained. Code samples are documentation, not apps.

But in this case, your additional code teaches an important lesson: do notifyListeners every time. So, this checks out.


void remove(Item item) {
_itemIds.remove(item.id);
// This line tells [Model] that it should rebuild the widgets that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to repeat the comment verbatim. The sample code should read like a tutorial of sorts.

Something like:

// Don't forget to tell dependant widgets to rebuild _every time_ you change the model.

icon: Icon(Icons.delete),
onPressed: () {
cart.remove(cart.items[index]);
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a trailing comma after } here.

@Alabhya268
Copy link
Contributor Author

@filiph I've made necessary changes please have a look .

@Alabhya268 Alabhya268 requested a review from filiph October 22, 2020 15:30

void remove(Item item) {
_itemIds.remove(item.id);
// Don't forget to tell dependant widgets to rebuild _every time_ you change the model.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is over 80 characters, please add a newline.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

nit: "dependent" is the correct spelling.


void remove(Item item) {
_itemIds.remove(item.id);
// Don't forget to tell dependant widgets to rebuild _every time_ you change the model.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1.

nit: "dependent" is the correct spelling.

@@ -46,6 +46,12 @@ class _CartList extends StatelessWidget {
itemCount: cart.items.length,
itemBuilder: (context, index) => ListTile(
leading: Icon(Icons.done),
trailing: IconButton(
icon: Icon(Icons.delete),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more correct to use a "remove" icon for the button, rather than a "delete" icon.

Consider this one, for example: https://material.io/resources/icons/?icon=remove_circle_outline&style=baseline

@Alabhya268
Copy link
Contributor Author

@filiph @redbrogdon , I've made the changes as requested ,let me know if anything else needs to be changed also I'm a big fan of "The Boring Flutter Development Show" , thanks for all your videos . They are pretty awesome. 💯

Copy link
Contributor

@filiph filiph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Alabhya268 Alabhya268 requested a review from redbrogdon October 23, 2020 23:48
@Alabhya268
Copy link
Contributor Author

@filiph if there is nothing that needs to be changed , could you please merge this PR .

@filiph
Copy link
Contributor

filiph commented Oct 26, 2020

Thanks for the nudge, @Alabhya268. Before I can merge, @redbrogdon first needs to approve (our repo is set up so that merging is blocked as long as there are reviewers without LGTM).

@Alabhya268
Copy link
Contributor Author

Thanks for the nudge, @Alabhya268. Before I can merge, @redbrogdon first needs to approve (our repo is set up so that merging is blocked as long as there are reviewers without LGTM).

@filiph thanks for letting me know this .

@redbrogdon redbrogdon merged commit 0188371 into flutter:master Oct 30, 2020
@redbrogdon
Copy link
Contributor

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cart should have trailing delete button to delete item in provider_shopper app.
3 participants