How can i make a column with many other things in it scrollable
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
flex: 10,
child: Stack(
children: <Widget>[..
Wrap the Column in a SingleChildScrollView widget.
If you want to have many other things scrollable you can look at slivers in flutter.
I believe they are a good fit for this.
Related
I am working the project and there is requirement to not use fixed width and height. However, I am getting pixel overflowed error. I used Expanded and other widgets but still getting an error. Code look likes this.
#override
Widget build(BuildContext context) {
return Scaffold(
child: InteractiveViewer(
minScale: 1,
maxScale: 1,
child: Center(
child: SingleChildScrollView(
child: Column(
children: [w],
),
),
),
),
);
}
In Column children we can add multiple children and page height grows with it. However, using Expanded widget is not solving the issue and getting pixel overflowed error. Using Container and MediaQuery is not required. Any solution will be appreciated. Thanks.
you can try this:
Container(height:MediaQuery.of(context).size.height,
width:MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Column(
children: [w],
),),)
Unfortunately the Keyboard hides the TextField if it gets opened.
I also tried resizeToAvoidBottomInset: true, but it remains causing Render OverFlow error.
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: getPrimaryDarkColor(),
resizeToAvoidBottomInset: true,
body: Stack(
children: [
Positioned(
bottom: -10,
child: Image.asset(
"assets/login_path_background.png",
width: 350,
color: getPrimaryColor().withOpacity(0.4),
),
),
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
How can I fix this?
wrap the body in a SingleChildScrollView
Wrap the Column in a SizedBox with device height as it’s height and the device width as it’s width. Then, inside that SizedBox, wrap the Column with a SingleChildScrollView. I had this same exact issue and just using a SingleChildScrollView does not work because the Stack item has no specific size or position. When you wrap the whole SingleChildScrollView in a SizedBox with the device size it works. Hope this helps!
I got a SingleChildScrollView looking like this:
Widget build(BuildContext context) {
return SingleChildScrollView(
physics: BouncingScrollPhysics(),
scrollDirection: Axis.vertical,
child: Container(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// ... some other widgets come here ...
CommunityListView(),
],
),
),
);
}
And the CommunityListView() inside of that is another SingleChildScrollView. My Problem is, once is scroll inside of the CommunityListView(), i can't get out of it and the user is stuck in this ScrollView.
Does someone know how I can fix that?
Thank you !
Please add physics to inner List as NeverScrollableScrollPhysics()
SingleChildScrollView is take height of their immediate child ..If you put SingleChildScrollView in their child then he can find the proper height so put height of first SingleChildScrollView's child then you can use it well
Hello there i got some troubles when i add a SingleChildScrollView on Column in the body of Scaffold widget i got full white Screein Please help
photos
https://pasteboard.co/K3Diclo.png
https://pasteboard.co/K3Diclo.png
whem i wrap it to SingleChildScrollView
i got a white screen (and lose my appbar)
Wrap your Column with a SingleChildScrollView.
Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
// Your items
],
),
),
);
I want to do a screen where there is a scrollable widget and a non-scrollable widget where the non-scrollable will be on top of the scrollable widget in dart flutter.
I have tried something this: pseudo-code:
Stacked(
children: <Widget>[
SingleChildScrollView(
child: // scrollable widget
),
Align(
alignment: Alignment.bottomCenter,
child: // non-scrollable widget eg container
),
]
)
But the scrollable widget is not scrolling. No error with this implementation but scrolling not working
The problem here is that the non scrollable widget is on top of the scrollable one and tends to block all the touch event to the bottom widget (the scrollable one.)
you have several ways to fix this, the first one is to wrap your non scrollable widget inside an IgnorePointer
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Stack(children: [
ListView.builder(itemBuilder: (context, index) {
return Text("item ${index + 1}");
}),
IgnorePointer(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(color: Colors.red.withAlpha(50))),
),
]));
}
but this will prevent any input on the overlapping widget
If you want to achieve the same, but being able to interact with the overlapping widget, you may want to change the IgnorePointer with a GestureDetector, and play with the behaviors https://api.flutter.dev/flutter/widgets/GestureDetector/GestureDetector.html