Manually select desired controls#794
Open
vinaykumarrock986612 wants to merge 1 commit intofluttercommunity:masterfrom
Open
Manually select desired controls#794vinaykumarrock986612 wants to merge 1 commit intofluttercommunity:masterfrom
vinaykumarrock986612 wants to merge 1 commit intofluttercommunity:masterfrom
Conversation
diegotori
requested changes
Nov 27, 2023
| class AdaptiveControls extends StatelessWidget { | ||
| const AdaptiveControls({ | ||
| Key? key, | ||
| required this.controlsType, |
Collaborator
There was a problem hiding this comment.
Please consider making this nullable and optional, so that it reverts to this class to determine the type of controls to render.
Comment on lines
+16
to
+29
| switch (controlsType) { | ||
| case ControlsType.cupertino: | ||
| return const CupertinoControls( | ||
| backgroundColor: Color.fromRGBO(41, 41, 41, 0.7), | ||
| iconColor: Color.fromARGB(255, 200, 200, 200), | ||
| ); | ||
| case ControlsType.material: | ||
| return const MaterialControls(); | ||
| case ControlsType.materialDesktop: | ||
| return const MaterialDesktopControls(); | ||
| case ControlsType.adaptive: | ||
| break; | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
Instead of having to duplicate code in this method, consider doing the following:
- Instead of using a separate enum for this, you may want to use an optional and nullable
TargetPlatformwhen creating this widget. That way if it exists, use that value, otherwise, fallback to the one from the theme. - Then you can determine the effective
TargetPlatformto use based on the above and pass that into the switch statement:
final effectiveTargetPlatform = customPlatform ?? Theme.of(context).platform;
switch (effectiveTargetPlatform) {
//...
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the controls are displayed based on the platform, and there's an option to choose build custom controls. But there's no option to use Cupertino controls as default if I want.
Added a high-level attribute to select desired controls type