How do i make scrollable column in body scaffold widget? - flutter

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
],
),
),
);

Related

How to ignore bottomNavigationBar with the Align widget?

Say there is a Scaffold with a bottomNavigationBar property that is populated. If you use a Stack with a Align widget inside its body set to Alignment.center, the Align widget gets centered accounting to the bottomNavigationBar and centers in the remaining space minus that.
How do I get it so that it centers according to the total screen height, using all these widgets?
Stack(
body: Align widget with center alignment and some child,
bottomNavigationBar: Bottom app bar
)
I'm not entirely sure what you mean in your question - but I think you want the body of a Scaffold (not Stack) to center a widget for the whole height available on the device.
Here's how you could do that using a Scaffold, SizedBox and Center widgets along with a MediaQuery
Scaffold(
body: SizedBox(
height: MediaQuery.of(context).size.height,
child: Center(
child: Text("CENTERED")),
),
bottomNavigationBar: BottomNavigationBar(items: []),
)
Scaffold
Sized Box
Center
Media Query
Hopefully that puts you on the right path.

Flutter: Incorrect use of ParentDataWidget, when using Expanded inside SingleChildScrollView

Below is the hierarchy of my Widgets. The SingleChildScrollView and Expanded were added simply because I wish to get the RefreshIndicator working.
Scaffold
SingleChildScrollView
Expanded
RefreshIndicator
Column
It was working until I upgrade my flutter recently and caused the following error Incorrect use of ParentDataWidget
I have did a search, the problem seems like because
Expanded widget can only reside in Column, Row or Flex
I put the expanded in any of the widgets above will results in either the refresh not working or another weird error.
Again, my main intention is to have my RefreshIndicator working inside a Scaffold.
In Flutter if you use SingleChildScrollView with Expanded then it will never work. And if you want to keep both widgets in your code then Wrap your Expanded with Column widget. Your Column widget should be parent widget of your Expanded widget , not in it's child widget.
But you don't need to use the expend widget for the refresh indicator. Just try with the below code:
Scaffold(
body: new RefreshIndicator(
child: SingleChildScrollView(
child: Center(
child: Column(
children: List.generate(50, (f) => Text("Item $f")),
),
),
),
onRefresh: _refresh,
),
)
//refresh function
Future<Null> _refresh() async{
print('refreshing........');
}

Is there anyway I can display all the contents of a Stack widget which has a List of dynamically created Positioned widgets as its children?

Here is my code for build method,
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Game Screen'),
),
body: Column(
children: [
Expanded(
//widget 1..
),
Expanded(
//widget 2..
),
Expanded(
flex: 3,
child: Stack( // Problem is with this stack widget
children: cardList, // dynamically generated list of Positioned Widgets.
),
),
],
),
);}
I tried enclosing this Stack Widget inside FittedBox widget. Hoping, that it would scale the contents of the Stack but sadly it gives an error saying that "The child of FittedBox should be Finite Sized". But my stack is displaying a dynamically generated list of Positioned Widgets so it could not be finite sized. Any workaround this?
P.S. I dont want to use List View, I want to scale the contents of the stack.. Just like how we witness it when using FittedBox Widget.

Wrapping Expanded Widget in Padding Widget

While learning flutter, I was trying to add some padding to an Image widget which was wrapped inside an Expanded widget, my approach was to wrap the Expanded widget with a Padding widget, but as a result the image actually overflowed.
When I changed the code to wrapping the Image widget inside a Padding instead, it worked fine. So my question here is, why did the image overflow when I used the Padding on the Expanded widget instead of the image ? Is it not possible to do that in Flutter ?
I am pretty sure your issue was not overflowing of the Expanded widget when you wrapped it with Padding, but rather Flutter threw an Incorrect use of ParentDataWidget exception. That is because widgets like Expanded and Flexible has to be direct children of Column, Row or Flex widgets. That is why the only solution is to use the Padding over the child of Expanded.
Summarising, this code will not work:
Row(
children: const [
Padding(
padding: EdgeInsets.all(8.0),
child: Expanded(
child: Icon(Icons.icecream_outlined),
),
),
Text("SomeTextyTextHere"),
],
),
it will not work because Expanded has to be a direct child of Row.
This code however will work fine:
Row(
children: const [
Expanded(
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(Icons.icecream_outlined),
),
),
Text("SomeTextyTextHere"),
],
),

Make a column scrollable in flutter

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.