Flutter making box inside box - flutter

ss
How can I make a box inside box like in the picture? when I tried make grey box and giving with but It takes all with it can.
return ListView(
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics()),
Children:[
Container(Here is black box),
Container(Here is Grey box),
Container(Here is badges),
],
);

Use the Stack & Positioned widget that helps to put the widgets where ever you want inside the stack.
Hopefully this can help you.

Related

How to show scroll indicator, Scrollbar on certain position of the screen? Flutter

Is there a way in Flutter to show a scroll indicator only on a specific widget?
For instance, I have the following widget tree
CustomScrollView(
slivers: [
sliverAppBar(),
sliverToBoxAdapter(), // horizontal list view
SliverList(delegate: SliverChildBuilderDelegate()) // show scrollbar only for this widget
],
),
Here is a demonstration of the iOS app Telegram, I have something similar in my app, notice when the header collapses a gray scroll indicator shows up.
Any idea on how to implement this behavior will be highly appreciated
You can use Scrollable List which provide you the nice way to fulfill your requirements

Flutter ListView bounces at the bottom but not on the top (iOS)

I have an app that contains a Widget which presents a ListView.builder with some custom Widgets in it (dynamic length).
For some reason, the list bounces perfectly fine on the bottom (over-scroll in the bottom), but does not bonce at the top (on over-scroll in the top).
I've tried to add this line of code:
physics: AlwaysScrollableScrollPhysics( parent: BouncingScrollPhysics() ),
as well as this one:
physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics() ),
But none of them worked.
Does anyone know how can I make the list bounce on both sides?
The top doesn't bounce because you set the shrinkWrap property of the listview to true.
Solution: set shrinkWrap to false and wrap your listView with a container() or sizedBox()
Check the video below for illustration.
https://drive.google.com/file/d/1_f1d0iY0XVOFi2RoCgbohk4CRhT0G08_/view?usp=sharing
Without actually seeing your code, it seems like you're using shrinkWrap: true property in your ListView which is preventing it to overscroll on the top (bottom works though).
If that's the case, your better bet is to use a Column wrapped in a SingleChildScrollView. Here's the minimal code:
SingleChildScrollView(
physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
child: Column(),
)

How to make background not scroll but foreground scroll?

I am use Flutter for web for make website. I need make foreground scroll, but background not scroll like normal website. For example: codemagic.io .
I cannot use Scaffold background because I want use use CustomPainter for custom background.
I am try use Stack, but issue is I need Center Widgets in ScrollView, and if I do this then the CustomPainter is not start from top of page:
Stack(
children: <Widget>[
Center(
child: SingleChildScrollView(
child:
Stack(children: <Widget>[
CustomPaintWidget(),
Widgets(),
],),
Anyone know solution?
Thanks!
You have two stacks here and one is only holding one widget (basically pointless for what you want to do). Put a widget on the bottom index of that stack (0) and make it the size of its container. You could use LayoutBuilder to get the size of its parent widget. Then place the singlechildscrollview on top of that.

Make a part of the screen scrollable in Flutter

I want to only make a part of my screen scrollable. When the number of items in my ListView exceeds 4 or 5 I am unable to place any widgets below this list view. I am not sure if there is a way to wrap all the contents of the listview to make that scrollable.
ListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: _getListings(businessListing),
),
This is my ListView and this is how the UI looks
The problem is when the number of RadioTile exceeds 8; the textField and the Button are pushed out of the screen.
I am wondering if it is good to make the entire screen scrollable?
Or make only a part of the screen containing the RadioTiles Scrollable?
Thanks,
To complete thebuggycoder answer if you want to keep only a part of your screen scrollable but keep variable height bottom elements, you can embed your ListView inside the Expanded of a Column, as shown below:
Column(
children: [
Expanded(
child: ListView(
children: _getListings(businessListing),
),
),
Container(
child: Text('This element must stay at the bottom'),
),
],
);
What are you doing there is basically telling your Column that it has 2 (or more) elements where each element usually takes the space it needs, except elements that are Expanded elements and will take "the maximum space left" in the Column.
There are a couple of points to consider:
If you plan to have more fields below the RadioTiles along with the Google Listing URL and the Save button, then it might be a good option to keep the entire screen scrollable.
On the other hand, if it's going to be just the two things below the RadioTiles, then it would be better to keep only the RadioTile list to be scrollable. This way the TextField and the Save button will always be accessible to the user without the need to scroll.
Also, you can decide about the scrolling depending on the priority of the fields. If the TextField and Save button have more priority then it would be best if they are always visible on the screen.
To make only a part of the screen scrollable, you can wrap the ListView in a Container with some fixed height, so that the it will scroll only within those bounds.
You will also need to change the physics property to AlwaysScrollableScrollPhysics().
Example -
Container(
height: 300.0 //Your custom height
child: ListView(
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
children: _getListings(businessListing),
),
)

Position widgets in stack without overlapping

I have a login screen with a logo on top. I want the login form to be exactly in the screen center (not in the center of the space below the logo). So far I managed to achieve that using Stack, roughly like this:
Stack(
children: [
Positioned(
child: Logo(),
left: 0,
top: 0,
),
Column(
children: [LoginForm()],
mainAxisAlignment: MainAxisAlignment.center,
),
],
)
In general, I am quite happy with how it looks, however, when the soft keyboard pops up, the visible screen size and the notion of the center change, the form moves up and overlaps with the logo. I know I can prevent widgets from resizing at all, but can I just allow the form move up only as long as it does not overlap with the logo?
You can use ListView instead of Column that will avoid overlapping with the logo and when keyboard opens, it will automatically scroll up the form.
Also note that, once you use ListView, use shrinkWrap: true inside it, as it'll only occupy the space it needs.
Hope this answer helps.