Flutter ClipPath Shadow - flutter

I'm trying to make a flutter container who's top edge is slanted, and additionally has a shadow following the slanted edge. It feel's like there should be a simple enough solution, but after experimenting with lots of different online articles and stack overflow posts, I still have not been able to produce this.
I've been using Clip Path to create the container that I need. Is there a simple way to create a shadow around the ClipPath?

Related

how to make a hole in a layer of stack or how to replicate the shown deisgn

Actually i am trying to make the following UI but i am not able to achieve that sort of hole or transparent layer below the yellow button. Have tried glassmorphism plugin and backgrop filters to acheive the glass frost efftet. Just would like to know how to make that hole.
Desired UI:-
You can use clipRRect or clipRect to make this design. these two widgets will help you cut/clip the container in the required shape.
For more information, you can have reference from here.

How to bend / crook a Flutter widget? (non-affine widget render transform)

Let's say you have some flutter widget, for example, a TabBar. It is rendered in a rectangular box. I need it to be rendered in an arc so that the text and the underline follow part of a circle (or better still, a bezier curve).
How can that be achieved?
This illustrates what I am trying to achieve - bent TabBar widget:
Please note that in this case, the TabBar bends following and an arc (edge of a circle). This is what I need immediately. However, in the future, I might need bending that follows the edge of an eclipse so a solution that allows it would be preferable.
Also, a solution that works for different widgets is preferred.
IMPORTANT: I do NOT want to clip a curved shape of the widget. The entire area of the widget should stay visible. Instead, I need to bend the content of the widget (=bend its render image).
Apologies for the bold font but without it, people will keep posting answers about how to clip a widget which is trivial in comparison and useless for my problem.
An answer "this is currently not supported by Flutter" from authority (e.g. high reputation in Flutter tag or Flutter a team member) will also be accepted.
One approach: Use a CustomPaint to draw lines/areas/etc freely
You can use a CustomPaint to draw whatever curved lines, areas, etc freely. Therefore, you can definitely achieve your goal - since they are nothing but curved lines, areas with curved edges, rotated texts, etc.
That will take a bit of work, but if you encapsulate it well enough, it is not that hard to implement. For example, draw a Path with filled red area, then draw a white arc, then draw several texts with calculated rotations, etc. Sounds like you can do that within maybe hundreds of lines. If you find difficulty implementing this please comment and I will explain.
Another approach: Hack Canvas such that the call to drawLine becomes indeed calls to drawPath, etc.
You may do the following to allow bend/crook for any widget (and their combination, of course), but this may need a bit of engineering. You can make your own Canvas, say, class BendCanvas implements Canvas {}. The BendCanvas.drawLine, for example, has an implementation of Canvas.drawPath with a curved path cooresponding to the input "line". Similar things hold for drawing rectangles, etc. Then you need to hack Flutter's painting logic, such that it takes in your own BendCanvas instead of the original canvas. This is a universal solution, and it is much more efficient (less code) if you plan to have a lot of bend UI; but if only on bend TabBar, maybe use the first approach.
As for the bend text
In the two approaches above, we have mainly described how you draw the bended rectangle (i.e. draw an arbitrary shaped widget). As for bending text, see: https://github.com/flutter/flutter/issues/16477 , which is still an open issue.
Remarks
It is not possible using transformations. As explained in the comments, you already see Transform does not work - it is affine or perspective, which, by definition, will not bend. Then what about other transforms? After some research there seems to be none. Then, what about looking under the scene. We know Flutter uses Skia under it to draw the UI with high performance, then let us search through Skia. However, it does not provide any transformations like bending. So there seems no use.
P.S. I am not that high reputation in Flutter tag, but I did answer >100 Flutter questions (including some dig-into-source-code style ones), and have developed >100k lines of Flutter code in the production app.

How to draw overlaying shapes in flutter

I'm trying to recreate a UI in flutter that looks like this I need to get this shapes in the position they appear in the image above, I did some research and came across Flutter Custom Paint, tried checking for tutorials on how to use it to achieve this design but can't find anything that points me in the right direction. Please is there anyway in flutter to recreate this UI?
Instead of complicating things
You can use stack for overlapping
And for that circles you can use containers with borderradius
and using positioned widget to position the circles based on your need
MORE THAN THIS
you can export that design as an image and use
Stack{
children[
THAT IMAGE,
YOUR UI,
]}

How to Have Lots of Moving Widgets in Flutter App

I know there are game/sprite engines written for Flutter, but my goal is to better understand painting and widgets, so I want to do this myself.
If I wanted a bunch of small widgets that could move around on a gameboard, what would be the best way to do this? Would I just create a box widget with fixed dimensions and have a bunch of children where I could control their position?
One example would be having a playing area with scrabble tiles that could be moved around. Or Tetris blocks falling. Different widgets that can be anywhere and that can be moved. I'm just looking for someone to point me in the right direction. Thanks.
You can draw custom shapes and lines using canvas in flutter and then animate them as flutter supports 60 frames per second. You need to understand customPaint very well. Here is a great demonstration of how to use customPaint to draw custom shapes.
https://medium.com/#rjstech/flutter-custom-paint-tutorial-build-a-radial-progress-6f80483494df

Overlay/translate ListView builder items clipped with a custom ClipPath

I'm generating multiple widgets(Containers in this case) using a ListView.builder and I also use a custom ClipPath to give a custom shape to them.
I was wondering if would it be possible to translate or somehow overlay those list items in order to place them so that the background(black area in the attached screenshot) would be covered. By that I mean I want to place them right under each other, like puzzle pieces. To be able to fit them right under each other would probably mean they would have to be overlayed somehow. Was googling but without any success.
Hopefully there's some Flutter experts out there who are nice enough to guide me. Thanks a lot!