Get all RenderObjects in viewport in Flutter - flutter

I have a long, scrollable list of widgets, and need to be able to restore the correct position in the list whenever the user switches from portrait to landscape, because the content is mainly text.
For now, I am using scrollable_positioned_list, but it isn't enough in some cases because its position is of course based on its immediate children. But when the child itself contains a bunch of other widgets, you get very imprecise positionning.
What I would want to do is to go down to the individual RenderParagraph or equivalent level, and look at their position in the viewport (using getOffsetToReveal for example) in order to position the scroll correctly.
In more descriptive steps :
I keep track of the "topmost" RenderObject,
The user goes from portait to landscape,
I scroll the list until the equivalent RenderObject is again the "topmost".
But to do that, I would need to get a listing of all RenderObjects currently in a given viewport, and I do not know how.
There also is visitChildElements, but the docs warns that is it potentially performance-intensive.
Thanks in advance. Other ideas around this problem are welcome too !

Related

3D wheel effect with list or scroll view

I need to create a list view that has a few key requirements
Infinite scroll of a fixed number of items (ie looping)
Multiple child item types (images, text, inputs)
Multiple child item heights
"3d" wheel look/feel. 2d perspective changes and shadowing/coloring should suffice
It needs to be iOS and Android compatible in Flutter.
I've tried the List Wheel Scroll View widget (https://api.flutter.dev/flutter/widgets/ListWheelScrollView-class.html) and am currently using Carousel Slider (https://pub.dev/packages/carousel_slider), but neither quite get the job done. List Wheel can't do interactive inputs or mixed child heights and the carousel can't do mixed heights or '3d'.
Has anybody created or come across something that might at least get me going in the right direction?
UPDATE
Currently playing with CustomScrollView with some success. It allows me to have multiple child heights and I ~think~ I'll be able to add some perspective to the children in the scroll listener.
What I can't figure out with CustomScrollView is how to get the looping/infinite scroll.
I liked using the flutter_swiper package a while ago. Not sure if it supports mixed heights, but it has 3D effects. But it doesn't seem maintained, so I would try this null-saefty unofficial fork : flutter_swiper_null_safety

Trying to understand RangeMaintainingScrollPhysics in flutter

I'm not sure I understand the use of RangeMaintainingScrollPhysics in Flutter.
What I have is a listview of variable items (think something like a twitter feed), and those items have images in them which dynamically load. If an image above your current position loads, then the listview item changes size and the whole list gets pushed down. The user loses his current position, which is annoying.
Reading the docs on RangeMaintainingScrollPhysics I thought that it would solve the problem I'm describing. But its not working for me at all, so either I am misunderstanding what it does or I misused it
Am I understanding what its purpose is?

GridView which keeps all elements instead of building them once on-screen

I have a grid view which is showing the heal status of many different services, and coloring them and/or auto-opening a webpage when the service goes down. The problem is that the elements which are off the screen are not being checked, which is more efficient, but not what is desired in this case.
I guess it's behaving similarly to the RecyclerView in android?
I want to be building the widgets which are checking service health even when they are not visible on the screen.
Currently the services don't start being checked until the moment I scroll them into the screen.
Assuming you are currently using the GridView.builder constructor, I recommend using the "normal" GridView constructor (with a children property). Since GridView.builder only builds the elements currently visible for efficiency reasons, the elements that are not rendered on the screen won't run your back end logic.
For more information, see the official docs:
[GridView.builder] constructor is appropriate for grid views with a large (or infinite) number of children because the builder is called only for those children that are actually visible.
Here you'll find alternatives:
The most commonly used grid layouts are GridView.count, which creates a layout with a fixed number of tiles in the cross axis, and GridView.extent, which creates a layout with tiles that have a maximum cross-axis extent.

Textfield draggable on Flutter

Do you know how can i make a textfield draggable on flutter and also that its height and its width increases while the user types (not predetermined) ?
The idea is put like every user can write something and move it across the screen.
Im savings the screen coordinates in order, that if the user enters from another device will see the text in the location he left it before.
If already tried with a code i found that uses positioned and stuff but since i have to predefine the width/height of the box, the offset location is not accurate when im showing it on other screen.
Thank you
Try using the InteractiveViewer,
https://api.flutter.dev/flutter/widgets/InteractiveViewer-class.html

Scrollviews and Cocos2D

I'm trying to develop a scrollable tile map in Cocos2D which uses an UIPanGestureRecognizer to do the dirty work, but while developing it, stumbled upon some problems for which I would like to ask for an advice.
The basic scrolling management works fine, it's precise and accurate and works by adding the translation recognized by the pan gesture manager to the tiles of the map. The problem is that the map is large and I just draw a small viewport of it, while I want to manage it like it's scrollable without any problem.
What I was thinking about is that, as soon as a whole row or column get out of the visible screen, it is moved to the opposite side, the corresponding texture rects are updated (I'm working entirely with a CCSpriteBatchNode), so that it will continuously update the viewport to make the whole thing work. This seems fine but I've found many problems in dealing with when to move the row/column, how to keep track of this issue (eg when pan changes direction from forth to back) and many little details which make me think that I should find a better approach.
Is there a common solution to my problem? That is: managing a scrollable viewport of a tilemap which should move over the whole map so the to the end user it seems like as if the map is infinite.
Thanks in advance
I solved my issue by developing a viewport in which rows and columns are effectively moved from left side to right side and from top side to bottom side.
This is done automatically when a new column or row enters the viewport and it's made by expanding the drawn viewport over the real one by an amount which is enough to avoid any graphical issue to the user.