How to proper structure Flutter design - flutter

I have stucked with an issue learning Flutter. I take a design from dribbble and try to implement it. The goal is to implement a horizontal scrollable list view but I want it to appear with padding and when I scroll it left it goes over the screen (see attachments). When I scroll left the items of the list should goes over the screen without padding. I tried to add empty sized box as first item of the list but it looks like incorrect approach. I am sure I am doing something wrong and it would be helpful if some one steer me in the right direction. .

ListView has a padding property you can use that.
ListView(
padding:EdgeInsets.only(left:10),
...
),
Hope this is what you are looking for.

Related

How can I make widgets move from right to left on scroll using Flutter?

I would like to know if there is a way to do something like this with Flutter. I need to get the widgets move from right to left on scroll. Please see the following GIF
https://ibb.co/9s3SgkW
It wouldn't be an exact behavior match, but you could try my package Entry, and more precisely Entry.offset(xOffset)

How to use SizeTransition with Text inside a Row without overflows

Problem summary
I'm building simple animation in which, simply, a panel expands to the right on a onTap event. The layout can be summarized as follows:
The panel has many tiles. Each tile has its own:
leading icon
title text
trailing icon
Each tile, when expanded, shows the three widgets above
Each tile, when shrinked, just shows the leading icon
The panel is scrollable to hold many icons such as these
At the end of the panel there's a simple icon which, when tapped, triggers the "expand" or "shrink" animation
The animation is built with an AnimatedContainer on the panel and a SizeTransition on the single tiles (via one single controller on the parent class)
The problem is simple: when the tiles shrink, their inner text overflows in the row.
Sample code
I just made this reproducible example on DartPad.
The obvious solution isn't helping me out
The most obvious solution is to simply wrap the Text inside a Flexible Widget: this advised by Flutter's docs and it makes sense, but unluckily it completely breaks my Layout.
Flexible introduces a flex factor that in this context is 100% unwanted.
I want my leading icons to be always at the end of the row, so my Spacer widget should "prevail" there.
I can't just play with flex factors there, as it would unintendedly hide text depending on its value.
Another code smell
Another thing I really don't like is the fact that I have to build a controller on the parent class, but I'm not actually using it on the parent class (I'm just exploiting it so I can give it to the children).
I'm new to animations in Flutter so I'm kinda confused on how I should orchestrate the whole thing here.
Any help will be appreciated / upvoted / accepted. Thank you!
As far as I understood you in a right way you just need set sizes for Row inside of SizeTransition instead of Container sizes
Here is your modified sample https://dartpad.dev/?id=a2408d29a1e8c6ce7a1cef8f21e7491d
I'd try an OverflowBox or a FittedBox (wrapping your text), depending on the result you want to achieve.

Paging by item Flutter

i would like to achieve pagination with flutter like this: every swipe gesture there i only one page swipped, and it is being centered in the screen. on the edges of the screen you can see parts of the next and previous items i.e the item is NOT THE SIZE OF THE SCREEN. this requirement is important. i can't set the item to be the size of the screen, also it should have padding between the items. for a better understanding i have a gif attached.
Thank you.
https://gfycat.com/soreheartfeltguernseycow
You can achieve the goal easily using PageView widget.
Ive found a class carousel_slider which is easily making that functionallity under the hood using PageView as suggested above.
For anyone who will need such behaviour as in the gif, see https://pub.dev/packages/carousel_slider

How to make stacked cards animate to go behind each other

I am trying to make a PageView with only 2 items. But I want to see the card behind the first one. And when swipe it to the right I want it to animate to the back and the back card animate to the front.
I have found a similar solution but not quite it,
Flutter Swiper. It does allow me to see the card behind however it's not as much as I want and it doesn't animate to the back instead it just disappears to the right. Also, I want to make it "pop-out" on the right and not on the left.
Any help would be useful to point me in a direction. Thanks.
Simply change the order of the children of Stack when needed:
var children = <Widget>[Widget1(), Widget2()];
Stack(
children: children,
)
when Widget2()'s position has been animated to the edge:
setState((){
children = <Widget>[Widget2(), Widget1()];
});

How to keep the scrolling position when adding a new elements in the top using ListView or CustomScrollView in Flutter

Is it possible to add new elements into the top of the ListVeiw or CustomScrollView and keep the scroll position as it's with Flutter
I've tried the following
extentAfter = _scrollController.position.extentAfter;
_scrollController.jumpTo(_scrollController.position.maxScrollExtent - extentAfter);
but this won't work well with SliverAppBar - floating and its actually not optimal solution.
Actually the cleanest way would be to add those items only when user scrolls back to the top of the ListView. You can cache them in memory for the moment user is far enough from the top (in your case) of the list.