Making a scrollable page in Flutter - flutter

so I'm trying to make a registration page with multi fields for name and password and email etc.
my problem is that i couldn't make the page scrollable, can please help me with fixing that
I just want the page to be scrollable
Here is my Code :
class InstRegisterPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0x47705C53), Color(0x9E36251D)],
stops: [0.1, 0.9],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
),
),
child: Column(
children: [
Container(
child: wLogo(),
),
SizedBox(
height: 75,
),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Color(0xFFF7F6F5),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(26),
topRight: Radius.circular(26)),
),
child: Column(
children: [
SizedBox(
height: 15,
),
CSfield('Particpent Name',''),
CSfieldEmail('Email',''),
CSfield('Password',''),
CSPasswordFiled('Phone Number',''),
CSButton(),
],
),
),
)
],
),
//child: InstHomePageWidgets(),
),
),
);
}
}

You can wrap your Column with a SingleChildScrollView to make it scrollable.
SingleChildScrollView(
child: Column(
children: [...]
),
)

You can check the page here to see all the scrollable widgets.
Also if the keyboard is pushes content up you can check this page

Related

Vote progress bar in Flutter

How do I create a voting progress bar in Flutter that starts from both end, where green extends from left side in green color if people voted YES and red extends from right side in green color if people voted NO . I have tried to find in Pub dev and can't find something like this. Would like to know how to create one as most of the tutorial I found, the progress bar only extends from one side instead of both sides. Something like this to clarify what I want to do
Maybe like this :
Widget _voteWidget(int yesVote, int noVote) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 20,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(30)),
),
child: Row(
children: [
Flexible(
flex: yesVote,
child: Container(
decoration: const BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.only(topLeft: Radius.circular(30), bottomLeft: Radius.circular(30)),
),
),
),
Flexible(
flex: noVote,
child: Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.only(topRight: Radius.circular(30), bottomRight: Radius.circular(30)),
),
),
),
],
),
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('${yesVote.toString()} Yes'),
Text('${noVote.toString()} Yes'),
],
)
],
),
);
}
use linearprogress indicator , if you want to add any decoration, just wrap with your custom widget
class MyWidget extends StatelessWidget {
int yes = 8736;
int no = 520;
#override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.all(20),
child: LinearProgressIndicator(
minHeight: 20,
color: Colors.green,
backgroundColor: Colors.red,
value: (yes / (yes + no)),
));
}
}
result:

Flutter Agora SDK Rounded Video SurfaceView

Does anyone know how to round the video corners in a video call? The container that I place them in has a border radius, but when the video starts it always shows a square container.
My video render code is below:
#override
Widget build(BuildContext context) {
return Stack(
children: [
_localSwitchRender == true
? rtc_local_view.SurfaceView()
: rtc_remote_view.SurfaceView(uid: widget.remoteUid.first),
Align(
alignment: Alignment.topLeft,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: GestureDetector(
onTap: _switchRender,
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 42, 0, 0),
child: Stack(
children: [
Column(
children: [
const SizedBox(
height: 20
),
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
color: Color(0x66333333),
),
width: 158,
height: 220,
foregroundDecoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
),
child: _localSwitchRender
? rtc_remote_view.SurfaceView(
uid: widget.remoteUid.first,
renderMode: VideoRenderMode.FILL,
)
: rtc_local_view.SurfaceView(
renderMode: VideoRenderMode.Hidden,
zOrderMediaOverlay: true,
),
),
],
),
],
),
),
),
),
),
],
);
}
}
Any help is greatly appreciated!
Place your widget inside ClipRRect:
ClipRRect(
borderRadius: BorderRadius.circular(10)
child: // your widget
)
Thanks Xoltwan! That worked:
ClipRRect(
borderRadius: BorderRadius.circular(10)
child: // your widget
)

Widget which adjusts to the children size?

Is there a widget in Flutter which adjusts itself on the content of it's children which are in Rows and Columns?
I can't seem to find anything related, and I am constantly hit with infinite overflows errors.....
As an example, lets say I would have 3 Widgets in a Row, 1 of which is a text, which I cannot guess how long it will be, but I need to expand the parent as much as the widget needs and at the sametime wrap the text
I would have something like:
Row(
children: [
Expanded(child: Widget1(....)),
Expended(child: Text(.....)),
Expanded(child: Widget2(....))
]
)
Right?
I would want the parent of the row to expand as much as it needs for the children to be shown, I want to align Widget1 and Widget2 in different ways (1-center, 2-bottom).
If I put them in Column I can center Widget1, but I cannot put Widget2 at the bottom because if I put Column to max size it overflows, if I don't it doesn't align...
How would you do it?
I really don't understand the logic behind the inifnite layout thing....
For example, here is where I am stuck at the moment.
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Global.findCategory(event.categId).color.withAlpha(150),
blurRadius: 20,
spreadRadius: -20,
offset: Offset(0, 5)
)
],
color: Colors.white,
borderRadius: BorderRadius.circular(30)
),
child: Row(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
width: Global.scaleSmallDevice(context) * 64,
height: Global.scaleSmallDevice(context) * 64,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
fit: BoxFit.cover,
image: event.image
)
)
),
)
,
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CustomText(
text: title,
color: Global.findCategory(event.categId).color,
fontSize: 16,
),
Flexible(
child: CustomText(
text: shortInfo,
color: Global.findCategory(event.categId).color,
fontSize: 12,
),
)
],
),
),
Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
Align(
alignment: Alignment.bottomCenter,
child: StatefulBuilder(
builder: (context, setState) {
IconData buttonIcon = (event.favorite) ? Icons.favorite : Icons.favorite_border;
return SplashButton(
splashColor: Global.findCategory(event.categId).color,
child: Icon(buttonIcon, color: Global.findCategory(event.categId).color, size: 30),
onTap: () async {
await event.setFavorite(context);
setState(() {
buttonIcon = (event.favorite) ? Icons.favorite : Icons.favorite_border;
});
}
);
},
),
),
],
),
),
],
);
}
In this case I want the StatefulBuilder widget to be on the bottom and the entire container be as small as the column with the CustomText widgets.
The widget with image inside I want it to be centered, while the text to be fully available to the user.
If I don't add a Column as Container, it goes as the height allows it and the StatefulBuilder widget center itself at the bottom, in the curent code it's at the center.....
Sorry if I'm not coherent, it's a bit late and I am tired after coding all day and stuck at this widget for a few hours.

Make soft keyboard overlaps other widgets - Flutter

How to make soft keyboard covers/overlaps other widgets instead of pushing them up which causes the UI to go crazy and pixels overflow?
I tried with and without Stack()
I tried with and without resizeToAvoidBottomInset: false,
But still no result!
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Stack(
children: <Widget>[
ClipPath(
clipper: CustomBackgroundClipper(),
child: Container(
height: 220.0,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
gradientStart,
gradientEnd
],
),
),
),
),
Container(
height: MediaQuery.of(context).size.height,
child: HomeTopContainer(),
),
],
),
),
);
}
}
Just add this in Scaffold :
resizeToAvoidBottomInset: false,
I donĀ“t know what is inside your HomeTopContainer, but like this way, its working to me:
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: <Widget>[
ClipPath(
child: Container(
height: 220.0,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.green, Colors.blue],
),
),
),
),
Container(
height: MediaQuery.of(context).size.height,
child: Align(
alignment: Alignment.bottomCenter,
child: Column(
children: <Widget>[
Spacer(),
Container(
height: 30,
color: Colors.red,
),
TextField()
],
),
),
),
],
),
);
}
}
I would suggest removing the Align widget completely and adding mainAxisAlignment and crossAxisAlignment properties to your Column widget.

Flutter : Applying One Gradient For Full Background

How can i apply a gradient like here to the app background? Can you see the gradient moving down on that the app bar and the scaffold body just like they were one widget and not 2 widgets that each has his own color?
You need to use container as background to your scaffold to add a gradient. You can use Opacity widget as well to make container or any widget transparent. But here is the exact solution what you are looking for:
Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF282a57), Colors.black],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(20, 50, 20, 0),
child: Container(
child: Row(
children: <Widget>[
Icon(Icons.menu,color: Colors.white,),
Spacer(),
Text("Expense",style: TextStyle(color: Colors.white,fontSize: 18,)),
Spacer(),
Icon(Icons.clear, color: Colors.white,)
],
),
),
),
],
),
)