Flutter - make Text() glide if its too long - flutter

So basically I want to make a widget that checks how much space is available and if there is not enough space to wait a few seconds and then slowly glide and stop at the start position. This process should repeat forever and optimally don't use too much performance. If did not get a clear idea of how I want the widget to behave, just look at the Spotify song names.

You can use an AnimationController with a custom animation which moves a Positioned widget containing the Text widget to make your own ScrollingText widget. There's another question where this exact problem gets covered in more detail. You can just copy-paste the code from there and you should be good.

Related

Flutter increase performance of large number of Positioned Widgets on screen

I'm making a grid of hexagons by placing Positioned Widgets. I have them inside an Interactive Viewer Widget so I can zoom in and out and move around.
Issue I'm having however is that with a large number of them being rendered it's far too laggy. It's unusable with about 4000 rendered on screen and ideally I need 10s of thousands. And this has nothing to do with the Widget itself as it's the same when replaced with a SizedBox with a Container or Text in.
I am using an InteractiveViewer.builder and only render the Widgets on the screen, which works great and there's no lag when zoomed in with few widgets on the screen, however I need to zoom out and see more.
I've also run in release mode and it's the same. I'm running in Windows and my PC is more than capable, too capable compared to the phones this should also be able to run on.
Is there some way to increase performance, or some other way I should be doing this instead of thousands of Positioned Widgets? Or is Flutter just not suited for this?
Edit: Image.
Using a widget for each individual hexagon at that scale feels like massive overkill. If you're going to use flutter, maybe use a CustomPaint widget, which allows you to draw shapes directly to a pixel grid?
You could wrap it in a GestureDector and implement scrolling and zooming via that perhaps?

Flutter - how to have a widget respond to touch and flick?

Currently in the design phase of an app. One of the goals we have is to be able to touch a certain widget, and on tap and hold, have the widget then follow the user's finger where they drag.
Then, if the user releases gently, the widget snaps back to the original location.
However, if the user flicks the widget, we want the widget to fly across the screen, reacting correctly to the user's flick.
Is there anything built-in that can handle this? Also, if this needs to be explained more to make sense, happy to elaborate.
Thanks!
I think for such cases you can use GestureDetector widget. It provides several useful functions. See here:
https://api.flutter.dev/flutter/widgets/GestureDetector-class.html
You can use onPanStart of GestureDetector and then get the offset and use it to move the widget accross the screen.

Circle/wheel ScrollView in Flutter

I'm having a hard time finding a widget I need in Flutter, which I thought wouldn't be that rare.
What I'm looking fore is something very similar to this:
Which is available at pub.dev, but doesn't have the flexibility I'm looking for.
Ideally, the widget I'm looking for wouldn't end like this one (when you keep scrolling it would go back to the first element). Also, I intend on stacking concentric wheel ScrollViews with different diameters.

How to get a widget to move across the screen every X seconds?

Basically I'm trying to build a game to learn flutter more.
Right now I'm just trying to get a Text widget to move from the top of the phone screen, towards the bottom of the phone screen... I'm building a Space Invaders type of game with just Text.
From what I've read by googling the problem, should I use Flame? Or can everything be done by just using the base Flutter framework (collision detection, moving widgets, etc...)? Thanks.
You can use Draggable class for dragging the item.
A simple way to solve this problem is to have the moving Text widget a child of the Stack() widget. Actually, the child of the Stack() widget is a Positioned() widget, which has left and top properties, which you can update periodically with a Timer.periodic function to move the widget down by incrementing top property. So, your Text widget is a child of the Positioned() widget, that you use for, well, positioning.
I have a working example of this in my slowly_moving_widgets_field project, where I have a bunch of arbitrary widgets moving about the screen every X seconds as you desire.

Flutter. Throw widget after dragging

I have been searching around for days in the jungle of widgets, trying to figure out which widget suits my purpose best.
What I have done so far: I have a Positioned widget with a listener, that I can drag around in a Stack with onPointerMove.
What I want to achieve is the following:
If I move my finger a bit faster and at some point let go, I would like to have the widget to continue with the given speed (with some friction) and direction (x,y) until it reaches some point.
Im a iOS developer and did this in Swift, but have I reached a point where I met the limit of Flutter?
Flutter has a Draggable widget which contains velocity in the onDragEnd event. You might use this and some basic animation to fling the widget using physics. Check out the Cookbook on the Flutter API site.