Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Mohamed-7018 wants to merge6 commits intoflutter:master
base:master
Choose a base branch
Loading
fromMohamed-7018:edge-insets-some-with-exceptSides

Conversation

Mohamed-7018
Copy link

📌 Summary

fixes#176470
This PR introduces several improvements to theEdgeInsetsGeometry utilities by adding new helper methods and thorough test coverage.

✅ Changes

  • Added new methods:
    • some() → CreatesEdgeInsets with all sides set to the given value.
    • exceptTop() → CreatesEdgeInsets excluding the top side.
    • Additional utility methods for more flexibility.
  • Added comprehensiveunit tests for:
    • some()
    • exceptTop()
    • Other utility methods.
  • Ensuredconsistency across the API surface.

🧪 Testing

  • Verified new methods produce expectedEdgeInsets values.
  • All test cases pass withflutter test.

🚀 Impact

  • Simplifies commonEdgeInsets creation patterns.
  • Increases reliability with full test coverage.
  • Prepares the package for future extensions.

🔗 Related

  • Resolves #<issue_number> (if applicable).

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 thegemini-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.

- 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.
@github-actionsgithub-actionsbot added the frameworkflutter/packages/flutter repository. See also f: labels. labelOct 4, 2025
Copy link
Contributor

@gemini-code-assistgemini-code-assistbot left a 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.

@Mohamed-7018
Copy link
Author

@fluttergithubbot I don't know why some checks failed, can you please help !

@justinmc
Copy link
Contributor

@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
Copy link
Author

Mohamed-7018 commentedOct 8, 2025
edited
Loading

@justinmc justinmc Actually using

EdgeInsets.all(16).copyWith(top:0);

we can achieve the same effect.
It effectively achieves the same result. However, having it at the constructor level:

  • Allows EdgeInsets to be const.
  • Prevents creating an additional copy.
  • Allows it to be expressed in a more concise way (and saves a few characters too). :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
frameworkflutter/packages/flutter repository. See also f: labels.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[Feature] Add EdgeInsets.some + exceptTop/Left/Right/Bottom constructors
2 participants
@Mohamed-7018@justinmc

[8]ページ先頭

©2009-2025 Movatter.jp