Rendering a flutter Widget to an opengl texture? - flutter

Let’s say I have a flutter module that provides a widget let's call it InterestingWidget. On the other side I have a native mobile application (ios/android) that displays a rotating cube with OpenGL. I would like to display the InterestingWidget on a face of the cube. Does this sound possible ?
Flutter seems to be able to render a widget to image ( Creating raw image from Widget or Canvas it seems there are problems with camerapreview or video widgets thought), so this step sounds possible.
I'm not sure if this can be done when the Widget is not in the rendering pipe though, the widget would need to render only on image.
Then we need to convert that image to opengltexture on native ios/android side, that sounds possible too with a bit of work.
And finally, I'm not sure about the interactivity, how to send simulated touches to the widget when user touches the face of the cube where the widget is rendered.

Related

Is there a way to way to use a VideoPlayer widget in place of an Image widget?

The panorama package on pub.dev only works with Image objects, but the premise should be the same if a video is used instead.
I want to modify this package to accept a VideoPlayer or VideoPlayerController widget from the video_player package. What are the things I must do to make it compatible?
The way panorama works is it takes the Image object and passes it to the package flutter_cube where it then makes a Mesh and texture out of it. The panorama viewing is done based off of this.
What I want to achieve is instead of Panorama accepting an Image widget, it should be the VideoPlayer widget. Width and height are really the only two variables needed so I wonder what I should do, those two are easily obtainable from the VideoPlayerController.

Can I use a Widget as a actual component in Flutter Flame

Can Flutter Flame render Widget inside game world like other components? (not overlay widget).
(I want to apply forge2d physic to widget and I'm trying to do it with Flame.)
You can not, you can only do it through the overlay system or use a Stack, but the widgets are never "in" the game, but on top of the game.
The game can only have Flame Components added directly to it.
You can still interact with the overlay widgets from the game though, like this for example: https://twitter.com/spydon/status/1417832832693673988
In that example I simply wrap the ElevatedButton with Positioned and Transform and then I updated those with the values from corresponding BodyComponents.

How to draw an animated logo using dart flutter as a splash screen

I am trying to create a dynamic logo using as a splash screen using dart flutter as the below image
So as the previous image this shield logo there's a way to create it dynamically using dart-flutter as to able to animate it easily as dragable those small squares in the shield logo...
There's a tutorial or docs related to this case could help me...
I hope this would be clear enough..
If there is no user interaction then you could use
Lottie animation or else if you want to have a user interaction with the animation to it then you could do like
ColorFiltered with the position
Update the state of the position from drag/click position

Render Flutter Widget on Canvas - CustomPainter

I was looking into building a game with Flutter. I have made multiple apps with Flutter already, but haven't really used the CustomPainter widgets a lot. I can make a lot of the UI I want to with Widgets rather than creating my own custom shape. So how do I convert a widget to an object that I can render on the canvas?

How to animate fullscreen photo transition on swipe, like in Telegram?

When you swipe vertically, image is dragged towards the swipe, with fading out animation of black background.
And after release, it smoothly returns to it's previous position on the screen, like Hero animation does.
How is it possible to recreate such an effect using Flutter? The same scenario, in fullscreen photo view.
photo_view package is desired for fullscreen, so it shouldn't interfere with zooming.
What you need is actually an out-of-the-box widget, and it's surprisingly easy to use. It's called Hero. Basically, you wrap the widget you want to animate like that in a Hero widget, with a specific tag string, and, when you navigate to another screen, you wrap the destination widget in another Hero with the same tag. An effect like the one you shared can be achieved by wrapping two widgets with the same photo with Heroes in different PageRoutes.
Check out this Flutter widget of the week video to get you started, and this Flutter.dev article for a more detailed explanation on Hero widgets.
Edit: I see you are looking for a more specific image-viewer behavior. Then, I suggest you use the photo_view package, which includes many functionalities to visualize images, including the hero transition with swipe-dow-to-dismiss behaviors, pinching to zoom, etc.
I found the solution.
To create such an animation, you should use extended_image package, which has SlideOutPage widget for creation of such transitions.