Skip to content

Conversation

@xclud
Copy link
Contributor

@xclud xclud commented Apr 6, 2018

Use the more generic EdgeInsetsGeometry instead of EdgeInsets. This enables to use EdgeInsetsDirectional as well and should be useful for Right-To-Left scenarios.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Apr 7, 2018
@Hixie
Copy link
Contributor

Hixie commented Apr 10, 2018

Where does it get resolved? Or is it passed through to something that already accepts EdgeInsetsGeometry?

@Hixie
Copy link
Contributor

Hixie commented Apr 10, 2018

(this will need tests)

@xclud
Copy link
Contributor Author

xclud commented Apr 10, 2018

For almost every padding enabled widget in Flutter we are able to set a padding either from a left-top-right-bottom or start-top-end-bottom because the padding property itself is a EdgeInsetsGeometry and we can assign values of type EdgeInsets or EdgeInsetsDirectional to it (child classes).

For InputDecorator this was not the case and i believe it is an implementation mistake. Currently we are unable to do the following:

new InputDecorator(
contentPadding: new EdgeInsetsDirectional...()
);

Above code will cause a compile-time error.

@HansMuller
Copy link
Contributor

I think this is a good improvement to make however I don't think this is the right way to make it.

InputDecoration.contentPadding and InputDecorationTheme.contentPadding should be EdgeInsetsDirectional and _InputDecoratorState should resolve contentPadding based on Directionality.of().

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2018

Where are the EdgeInsets values actually used? Are they just passed on to Paddings or such, or are they directly used somewhere?

@HansMuller
Copy link
Contributor

They're directly used (in a way where start/end resolution matters) by the InputDecorator's renderer at performLayout() time

@Hixie
Copy link
Contributor

Hixie commented Apr 12, 2018

Ah yeah in that case this patch will indeed not work, and we'll have to resolve them before use. I'm surprised the code above compiles without analyzer warnings, actually.

@Hixie
Copy link
Contributor

Hixie commented Apr 25, 2018

@xclud Will you be able to continue working on this (to address the comments above)? It's totally fine if not; we can take it over (though it might take longer). I'm just asking because I'm trying to clean out our review queue.

@xclud
Copy link
Contributor Author

xclud commented May 3, 2018

@Hixie I want to bring your attention to the field type of contentPadding which is EdgeInsets in the InputDecoration class.

On the other hand, for the rest of the Widgets padding field is of type EdgeInsetsGeometry. Take SingleChildScrollView as an example, here is the padding field:

final EdgeInsetsGeometry padding;

I believe the InputDecoration case is a mistake. Being EdgeInsetsGeometry allows us to use a value of type either EdgeInsets or EdgeInsetsDirectional.

@Hixie
Copy link
Contributor

Hixie commented May 3, 2018

Yes, it's definitely a mistake. The fix is not just to change the type though. We have to change the type, and resolve them (using EdgeInsertsGeometry.resolve) before using them.

@HansMuller
Copy link
Contributor

I'm making an InputDecoration change now, will fix this as well.

@Hixie
Copy link
Contributor

Hixie commented May 29, 2018

@HansMuller Is this resolved now?

@HansMuller
Copy link
Contributor

This was fixed in #17292

@HansMuller HansMuller closed this May 30, 2018
@xclud
Copy link
Contributor Author

xclud commented May 30, 2018

Thank you for the great job. Fixed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants