Skip to content
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

Use SizedBox.shrink(...) and SizedBox.expand(...) constructors appropriately #2072

Closed
domesticmouse opened this issue Apr 19, 2020 · 2 comments · Fixed by #3039
Closed

Use SizedBox.shrink(...) and SizedBox.expand(...) constructors appropriately #2072

domesticmouse opened this issue Apr 19, 2020 · 2 comments · Fixed by #3039
Assignees
Labels
lint-request type-enhancement A request for a change that isn't a bug

Comments

@domesticmouse
Copy link
Member

Describe the rule you'd like to see implemented

Implement a lint rule that catches usage of the normal SizedBox(...) constructor
that should instead use the SizedBox.shrink(...) and SizedBox.expand(...)
constructors instead.

This is a follow on from #2049 (comment)

Examples

BAD:

Widget buildLogo() {
  return SizedBox(
    height: 0,
    width: 0,
    child:const MyLogo(),
  );
}
Widget buildLogo() {
  return SizedBox(
    height: double.infinity,
    width: double.infinity,
    child:const MyLogo(),
  );
}

GOOD:

Widget buildLogo() {
  return SizedBox.shrink(
    child:const MyLogo(),
  );
}
Widget buildLogo() {
  return SizedBox.expand(
    child:const MyLogo(),
  );
}
@domesticmouse domesticmouse added type-enhancement A request for a change that isn't a bug lint-request labels Apr 19, 2020
@domesticmouse
Copy link
Member Author

@bwilkerson and @pq I'm happy to have this bug assigned to me to implement, if we decide this lint is worth having.

cc: @a14n

@pq
Copy link
Member

pq commented Apr 20, 2020

SGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants