corner_radius_plugin 0.0.5
corner_radius_plugin: ^0.0.5 copied to clipboard
Flutter plugin to get device screen corner radius on Android and iOS
0.0.5 - 2025-11-26 #
- feat: Allow setting default radius during plugin initialization
0.0.4 - 2025-11-26 #
- Fixed isolate not working as expected
0.0.3 - 2025-10-07 #
- Device dataset Updated
0.0.2 - 2025-10-07 #
- Device dataset Updated
0.0.1 #
- Initial release.
Highlights
- Public API:
CornerRadiusPlugin.init(),CornerRadiusPlugin.screenRadius, andCornerRadiusPlugin.setDefaultRadius(double)to initialize, read and configure a fallback radius. - Data model:
CornerRadiusvalue object with per-corner radii (topLeft,topRight,bottomLeft,bottomRight). - Android support: Uses Android 12+ RoundedCorner APIs (via WindowInsets)
to return per-corner radii. On older Android versions falls back to the
rounded_corner_radiussystem dimension when available; otherwise returns zeros (or the configured default radius). - iOS support: Bundles
assets/bezel.min.json(BezelKit dataset) and looks up device-specific bezel/corner radius by model identifier (e.g.iPhone14,2). The JSON lookup runs on a background isolate to avoid blocking the UI. - Method channel platform interface:
getScreenRadius()andgetDeviceInfo()are implemented via method channels so platform implementations can be overridden in tests or by federated plugins.
Behavior and usage notes
- Call
await CornerRadiusPlugin.init()early in app startup (for example inmain()orinitState) to populateCornerRadiusPlugin.screenRadius. - On iOS the plugin queries the native platform for the device model and
device type then performs a JSON lookup in
bezel.min.json. If the lookup fails or returns zero, the configured default radius will be used. - Use
CornerRadiusPlugin.setDefaultRadius(5.0)to set a non-zero fallback radius for devices where native APIs or dataset entries are unavailable.
Assets and maintenance
assets/bezel.min.jsonis included in the package and is intended to be periodically updated (the project contains an auto-update workflow in the example README). The plugin reads the JSON from package assets at runtime.
Attribution
- Android logic adapted from
screen_corner_radiusby ivangalkindeveloper: https://github.com/ivangalkindeveloper/screen_corner_radius - iOS bezel dataset and lookup approach via
BezelKitby markbattistella: https://github.com/markbattistella/BezelKit
Developer notes (internal)
- The Dart implementation exposes a platform interface in
lib/src/corner_radius_plugin_platform_interface.dartand a method channel implementation inlib/src/corner_radius_plugin_method_channel.dart. - The lookup helper
_lookupBezelForModelis run on a background isolate viacompute()and loads the JSON frompackages/corner_radius_plugin/assets/bezel.min.json.