how to "dark out" widgets in the background? - flutter

I want to "dark out" all widgets, except a special widget which the user is working with.
This special widget should be on a predefined position. Everything else should be "darked out".
Is there an easy way to acchieve a result like this?
What I did is:
- put on every element an overlay except one element
The problem is that this overlay is not laying over the whole screen (you see it ends on the top of my picture and I think this solution is not the cleanest as it is very complicated to control:

What you describe sounds like modal barrier color, and modal barrier behavior. The easiest way to achieve that is by using showDialog function.

Related

Is there a way to know the dimensions of a widget before laying it out on the screen?

I'm trying to implement a breadcrumb widget in my Flutter app and I would like to achieve the following behavior:
Let's say the red outlined area is the space I have for my breadcrumb and that each element of the breadcrumb has a different width. The breadcrumb should be responsive, i.e. it should show elements as long as there is enough space to show them, otherwise, remove some of the elements and add that '...' button in the middle. Clicking on that button shows an overlay that contains the removed elements.
Now, I want to know how much space each breadcrumb element will take before it is laid out on the screen. Only then, I can decide whether there is enough space for it to be shown in the breadcrumb or it should be part of the '...' button.
I tried to use CustomMultiChildLayout which gives you information about how much space a widget takes after laying it out. It also needs to layout each child once, which makes it unuseful in my use case.
P.S: Think about the breadcrumb used in the apple documentation. That's the same behavior I want to achieve.
Short answer, you can't.
You were already using CustomMultiChildLayout, that's good, it shows me that you should have some basic understanding of how flutter rendering pipeline works. Then it should be clear to you of the 3 steps: parent passes down constraints, child reports its size, parent decides where to place the child. So in short, again, you cannot get children's size before layout.
Now move on to the thing you want to achieve. I agree CustomMultiChildLayout cannot achieve what you want to do, but not for the reason you listed. The main problem is CustomMultiChildLayout forces you to layout each child once, and then position them. You must position each child, you cannot skip a child if you don't like it (too big), and you cannot fabricate new stuff that's not your children. If you could achieve these 2 things, then getting children's size after layout isn't going to be a problem.
To achieve those, the easiest way is to use CustomPaint, if everything you need to do, are text-based or just simple shapes. Use TextPainter to layout a text, get its size, then decide whether to paint that text, or paint "..." (skip a child and fabricate your own) instead. You can search on how to do these things easily, but mostly search on TextPainter.
If you want to paint other widgets as your children, and optionally skip some of them while fabricating others, you should write your own RenderObject. That is one level lower than "widgets-level". If you have never done that before, you can research on that topic as well.

Flutter. ColorFiltered with click through it

I am using this
ColorFiltered(
colorFilter: ColorFilter.mode(Colors.black54, BlendMode.srcOut),
....
In order to create an overlay over my entire screen and then I cut out a section of it in order go highlight a widget which is below this overlay. Something similar to this:
My problem is that the widget behind it, is not clickable. The overlay consumes the click. How can I mark just that particular zone, to be clickable ? Nothing more, nothing less.
EDIT
I know I could use IgnorePointer but ... if I set it as a parent to ColorFiltered it'll just allow all the widget behind the overlay to be clicked. I need it to work ONLY on the highlighted area.
I'm starting to thing I need to rethink the highlighter, in order to achieve this functionality. Am I right ?

How to check visibility of a Flutter widget even when covered by another

I'm trying to find a way to check the visibility of a Flutter widget when it's either off screen or when it's obscured by another, for example Drawer, Dialog or BottomSheet.
visibility_detector helps with checking whether it's on the screen or not but does not work with the second use case (known limitation).
Is there a lower lever api that I can use to check whether a widget is actually visible to the user?
My use case: I'm adding a widget to the Overlay when something external happens (similar to Tooltip but not on long press). If the user opens for example the Drawer, the widget will appear on top. I want to detect that the child is not visible and delay or cancel the action.
Do I understand your problem?
You have a widget you want to always be on top?
You want the user to interact with that widget first before doing other things?
Use design patterns to make coding easier, your users will thank you.
You can show a Dialog on-top of other widgets with the showGeneralDialog or showDialog functions. Because Dialogs are a design-pattern used in many apps, users will already know how to use them.
Define app behavior with explicit state.
It is too hard to derive app behavior from rendered UI, not all devices are the same size and shape. This means you should try to write a variable that describes your situation and then write the code you need to make that variable's value correct. It sounds like you want a variable like bool overlayIsShowing.

Is there any similar widget or function like 'showModelBottomSheet' that pop on screen from right hand side in flutter?

I used showModelBottomSheet a lot that pops on the screen from the bottom with a nice animation.
Now I want to use something similar that pops on the screen from the right-hand side instead of the bottom.
It helps me a lot for UI purposes when the user rotates the screen to landscape, then I want to show a pop up from right in the flutter.
I tried to find and also dig deeper inside showModelBottomSheet function but no luck.
Try using drawer on right side it may solve your problem
answered in link below
How to place Drawer widget on the right
I don't think that exists either in Material or Cupertino design language, so no, unfortunately. However, you could build that yourself pretty easily with a Stack widget.

Flutter Widget Overflow Parent (Tabbar Oversized item)

I would like to have a tab bar that looks like this:
Note the center "My ID" button.
So here is my main problem:
Obviously I need a SafeArea to deal with irregular shaped screens, which itself need to be embedded in a Container so I can give the bar its background color. But, by doing this, how can I create the "oversized" button at the center?
After spending several hours banging my head against the wall, found a not so elegant solution. (Hey, but it works)
Here's a picture of the result.
So the way I made it work is actually by having two layers.
On the base of the widget tree is a Stack which contains everything that is currently seen on this page.
The actual bar widget has the text and icons, (the My ID part has only text no icon, but a placeholder SizedBox is used in place of the icon otherwise would be there)
By using the stack, I am able lay the round icon on top of the entire bar much like a FloatingActionButton