- Notifications
You must be signed in to change notification settings - Fork29.3k
Extend EdgeInsetsGeometry with Utility Methods: add EdgeInsets.some and EdgeInsets.except constructors#176507
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Conversation
- Added `EdgeInsets.some` and `EdgeInsetsDirectional.some` for creating insets where all sides share a default value, with optional overrides.- Added `EdgeInsets.exceptTop`, `EdgeInsets.exceptBottom`, `EdgeInsets.exceptLeft`, and `EdgeInsets.exceptRight` for convenience in creating uniform insets except for one side.- Added `EdgeInsetsDirectional.exceptStart` and `EdgeInsetsDirectional.exceptEnd` for direction-aware insets with one side excluded.- Updated documentation for all new constructors.- Added comprehensive unit tests to cover `some` and `except*` constructors, including LTR/RTL resolution.
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.
Code Review
This pull request introduces new utility methods toEdgeInsetsGeometry
,EdgeInsets
, andEdgeInsetsDirectional
to simplify creatingEdgeInsets
instances. Specifically, it addssome()
constructors to create insets with a default value for all sides that can be individually overridden, andexcept...()
constructors to create insets where all sides have a given value except for one. The changes also include corresponding factory constructors onEdgeInsetsGeometry
and comprehensive unit tests for the new functionality.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@fluttergithubbot I don't know why some checks failed, can you please help ! |
@Mohamed-7018 Are any of these currently not doable with the current APIs? I hesitate to add API bloat to this class without a clear idea of significant benefit for users. |
Mohamed-7018 commentedOct 8, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@justinmc justinmc Actually using EdgeInsets.all(16).copyWith(top:0); we can achieve the same effect.
|
📌 Summary
fixes#176470
This PR introduces several improvements to the
EdgeInsetsGeometry
utilities by adding new helper methods and thorough test coverage.✅ Changes
some()
→ CreatesEdgeInsets
with all sides set to the given value.exceptTop()
→ CreatesEdgeInsets
excluding the top side.some()
exceptTop()
🧪 Testing
EdgeInsets
values.flutter test
.🚀 Impact
EdgeInsets
creation patterns.🔗 Related
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel onDiscord.
Note: The Flutter team is currently trialing the use ofGemini Code Assist for GitHub. Comments from the
gemini-code-assist
bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.