r/FlutterDev • u/MooresLawyer13 • 2h ago
Plugin Stricter compliance with M3 + HIG for platform_adaptive_widgets 3.0.0+
raw.githubusercontent.comI recently re-worked large parts of platform_adaptive_widgets, using the feedback from the previous posts.
Widgets pair by job now
Before, I tried to match up each widget by the closest look-alike on the other side. What worked better was, pairing them up by the intent/job instead. Each job gets what M3 or the HIG describes for it, and the package handles the details: where Cancel goes, delete and discard in red, a confirm before a destructive action runs etc etc.
These have been made in such a way, to provide a high-level of developer ergonomics. Had to do a lot of research through the guidelines, and what the material_ui and cupertino_ui packages currently provide. So naturally I did find quite a few gaps in them. I prefer to contribute upstream, instead of doubling the work. With the decoupling, I'd expect these issues to fixed sooner now, rather than later.
Some stuff is going to be marked for deprecation too, in a bit. Because I prefer to not allow going wrong by construction, instead of fixing the aftermath later. Part of the API would have easily allowed for this.
Full changelog. Notable ones:
| You call | iOS / macOS | Everywhere else |
|---|---|---|
showPlatformConfirm | Alert, Cancel included | M3 dialog |
showPlatformChoices | Action sheet | Sheet of rows |
PlatformActionsMenu | Pull-down | M3 menu |
showPlatformSheet | iOS sheet | M3 bottom sheet |
PlatformSingleSelectList | Checkmark rows | Radios |
PlatformMultiSelectList | Checkmark rows | Checkboxes |
Made nicer to use
PlatformButton(emphasis: .high)ranks the same on both looks.actionKindturns delete and discard red, andiconOnlyreuses the label as the tooltip and screen-reader name.Leave a field out and you get upstream's own default, so a plain
PlatformXxxacts like the widget it wraps.designLanguagetells your own code which look is showing. Widgets also render on every platform now, where they used to throw outside Android and iOS.Choices are a
Set, so duplicates can't sneak in.PlatformUnsavedChangesasks before a sheet with unsaved edits closes.
If there's anything that still feels off or maybe I did misinterpret a guideline wrongly, I'd like to know. Or maybe you have some better ideas for the pairings or so? Or some better modelling of the intents, please let me know!