Repository navigation
Deprecate CupertinoDialog class #20397
Description
CupertinoDialog and CupertinoAlertDialog have both existed for some time. For that time both dialogs have been rendered in a manner that does not match iOS accurately. Both dialogs essentially treated an iOS dialog as a generic modal comprised of a blurred rounded rect + some content. But this isn't what a dialog really is in iOS.
iOS only offers an alert dialog. There is no generic dialog. The alert dialog separates content from buttons with gap dividers that show through to the blurred area behind it. This is a very specific layout policy and therefore it does not generalize to some universal concept of a dialog.
Thus, CupertinoDialog is neither an existing iOS UI element, nor is it a faithful generalization of iOS layout and rendering policy. As a result, we should eliminate CupertinoDialog. Developers should either use CupertinoAlertDialog as a direct replacement for an alert dialog in iOS, or developers should create whatever their custom modal is (because no other modal is a legitimate iOS replica).
PS - If there are building blocks that we should provide to make it easier for developers to make iOS-ish dialogs, that may be completely legitimate and I'm happy to consider creating those building blocks.
Activity
Hixie commentedon Aug 9, 2018
Ideally, CupertinoDialog would just be the blurring part of CupertinoAlertDialog, I think, so that people who want to create new kinds of dialogs that look like iOS dialogs would get the same blurring effect for free.
matthew-carroll commentedon Aug 9, 2018
@Hixie @xster pulling conversation here from email thread. Looks like both of you said the same thing.
I think if we want to provide some kind of blurred box (which still won't do anything for people that need gaps), then I think we should offer it with a name that suggests a building block. The name CupertinoDialog seems far too official and high-level to me...the thing we're rendering is not a "dialog". Sure, it's modal, assuming you launch it with showDialog(), but that's completely outside the purview of what the current CupertinoDialog is doing. It really is just a rounded rect with a particular blur applied to it. It doesn't even include the white color on top because the alert dialog needs to add that with custom render objects.
So if you really think people need the blurred rectangle then I would like to give it a much more accurate name.
If not, then I'd like to get rid of it.
xster commentedon Aug 10, 2018
Sure, sounds reasonable. https://github.com/flutter/flutter/pull/7395/files#diff-dc35a23fd1ef0ca6af75e4a62218b990R58 's intent is more like a CupertinoDialogContainer or CupertinoDialogFrame than CupertinoDialog so we're stuck with the API break anyway. I'm ok with removing it.
matthew-carroll commentedon Aug 10, 2018
@xster I'm not sure the word "dialog" belongs at all. This blurred box would be the same thing that is used for the action sheet, too, right?
matthew-carroll commentedon Aug 10, 2018
Spoke with @Hixie offline. We're going to introduce a "CupertinoSurface" that knows how to render these blurred boxes. We're going to mark CupertinoDialog as deprecated and have it extend CupertinoSurface. Eventually we can delete CupertinoDialog when usages minimize.
xster commentedon Aug 10, 2018
I would just be cautious of overgeneralizing that class as well since it's not like
class Material extends StatefulWidgetwhich is used a bit everywhere. It's rather something like a CupertinoModalOverlaySurfacematthew-carroll commentedon Aug 10, 2018
I agree with the sentiment. We discounted "overlay" because it already has a very specific meaning in Flutter. Modal concerns me a bit because I'm not clear on the definition of "modal". Does it include action sheets? Is anything that appears on a dark background considered a modal? What if iOS decides to use this blur effect in other situations?
So I could probably get behind CupertinoModalSurface, but I need some convincing that we won't regret the "modal".
xster commentedon Aug 10, 2018
How's CupertinoPopupContainer?
Modal is just anything that appears on top of something else that you need to deal with before going somewhere else. So it includes action sheets but I'm worried maybe one day it's possible that this thing summons something on top of it while remaining in the navigation stack.
Popup is simple because by virtue of blurring and having a rrect, it implies it's on top of something else and covering it partially. If we either change the name or the implementation, they'll disconnect so much that we already broke the user's intent anyway for using it in the first place that they might as well already use a different API.
Surface->Container to avoid conflating with Android surfaces and Container parallels what we mean with the word 'container' in flutter already.
matthew-carroll commentedon Aug 10, 2018
I think I prefer CupertinoModalSurface on both counts.
Modal seems more general than Popup, which I think is preferable.
Container I think goes the wrong direction all the way. This thing is only a container in so far as it takes a child, but that's pretty much every widget in Flutter. What this thing is really providing is a particular kind of surface upon which you can paint whatever you want as a developer.
Also, I think naming something similar to the existing Container is more likely to confuse people than sharing a name with an Android SDK class that refers to texture rendering.
Hixie commentedon Aug 13, 2018
It's not clear to me that "modal" is the right term. I could totally imagine using this for entirely non-modal widgets, e.g. tooltips, especially if we aren't including the scrim as part of the widget (it's in the route).
CupertinoPopupSurface?
matthew-carroll commentedon Aug 13, 2018
@Hixie how is a popup different than a modal?
And if you're not confident that it will only be used as a modal, what makes you confident that it will only be used as a popup?
[-]Remove CupertinoDialog class[/-][+]Deprecate CupertinoDialog class[/+]Deprecated CupertinoDialog in favor of a new widget called CupertinoP…
Hixie commentedon Aug 15, 2018
Modal and popup are orthogonal concepts. "Modal" means that you have to deal with the thing before you deal with the next. For example, the Emacs minibuffer is modal. "Popup" means that it is overlaid on top of other content. For example, notifications from chat clients are popups. One example of something for which you might use the feature here is the volume up/down overlays on iOS.
Deprecated CupertinoDialog in favor of a new widget called CupertinoP… (
victorsanni commentedon Jul 29, 2024
Closing because this seems to have been fixed by #20649
github-actions commentedon Aug 13, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.