How do I put two text fields side by side on flutter - flutter

Hello I have a flutter form where the user will enter his card details. I want it to look exactly like in the picture below
I already know how to put the 'Number' and 'Card Holder' text fields. How do I put the Expiry Date and CVV text fields side by side like above?

Use the Row widget and put these two text widgets as children.
Example
Row(
children: [
Text( 'Expired Date'),
Text('CVV'),
],
),

Very simple row widget is used for side by side container
Column widget is used for side under side
Row(
Children [
Container (Text(’row 1’),
Container (Text(’row 1’)
],
);

Related

How to use Expanded with e.g. GestureDetector on path from Column to Expanded

I currently create an editor, which allows to insert new items at certain places in a two dimensional plane.
The editor places items on the screen and wraps them in GestureDetector() or DragTarget() to allow to drop in new editor items.
Therefore, structures like this appear often, to show editable items in a property inspector widget, if the user clicks on the Expanded() Widgets area:
Column(
children: [
DragTarget(
builder: (context, candidateData, rejectedData) {
return Expanded(
child: Text( 'X' ),
);
},
)
],
)
This, as well as GestureDetector(), generates this render error:
Incorrect use of ParentDataWidget.
The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of
type FlexParentData to a RenderObject, which has been set up to accept
ParentData of incompatible type ParentData.
Usually, this means that the Expanded widget has the wrong ancestor
RenderObjectWidget. Typically, Expanded widgets are placed directly
inside Flex widgets. The offending Expanded is currently placed inside
a MetaData widget.
If I remove the DragTarget(), the tree renders fine:
Column(
children: [
Expanded(
child: Text( 'X' ),
)
],
)
Q How to make an Expanded() a DragTarget() or a GestureDetector() child?
Needless to note, that the problem appears with any compile target.
Since the editor allows to drop widget like Column, Card etc., I need a generic solution.
As the documentation says:
Using an Expanded widget makes a child of a Row, Column, or Flex
expand to fill the available space along the main axis (e.g.,
horizontally for a Row or vertically for a Column).
That means you can only use the Expanded widget as direct child of a Row, Column or Flex. That is also why your snippet works without the DragTarget since in that case the Expanded is a direct child of your Column.
To fix your problem you could do something like this:
Column(
children: [
DragTarget(
builder: (context, candidateData, rejectedData) {
return Column(
children: [
Expanded(child: Text( 'X' ))
]
);
},
)
],
)
You could also wrap your DragTarget into an Expanded widget. It's hard to help you exactly without more information. But both ways atleast wont return an error.

How to Keep the elements on ends in Row() widget in flutter?

I am using below Row widget in flutter , which is nested in a Column widget and on screen it appears shared in the screenshot
I want to the Row elements to appear at extreme ends with some padding. How can I do that?
Row(
children: [
SizedBox(width:20,),
Text("Mark ALL READ"),
SizedBox(width:200,),
Text("Clear All"),
],
),
Setting the mainAxisAlignment property of the row to MainAxisAlignment.spaceAround should place the elements on both ends of the row.
To add some padding you should be able to just place the whole Row() widget into a Padding() widget.

Flutter: How to make such Edit text and remove the unexpected layout padding

I'm trying to implement this design:
i'm very beginner to flutter, and what i'm getting is this:
I don't want you guys to get me wrong, i'm not asking for someone to implement this for me.
i need guidance on how to:
remove the layout padding.
make a textview and edit text side by side look like one widget.
remove the space between the edit texts.
implement the CheckBox (i tried a row with check box and text, didn't work)
show a proper arrow in "Sign In" (instead of ->).
just some explanations, guidance and any documentation or tutorial that could be good for my case.
Here is my code
remove the layout padding.
make a textview and edit text side by side look like one widget.
Im not sure of this if your talking about inside TextFormField you can use contentPadding inside InputDecoration. But based on your layout design, you can separate the Label in TextFormField and create your own label text
Row(
children:[
Text("LABEL"),
Expanded(
child: TextFormField(),
)
]
)
4.implement the CheckBox (i tried a row with check box and text, didn't work)
Row(
children: [
Checkbox(
value: isValue,
onChanged: (bool value) {
setState(() {
isValue = value;
});
}),
Text("SOME TEXT"), //Read RichText widget for your design
],
),
For you arrow -> sign in
Try using Icon() widget

Scrolling Widget inside a Constant size Container flutter web

Hi all fellow developers,
I am developing a responsive web page in flutter using the flutter web SDK, but i am stuck at one part of the page where i have a Row inside row I have 2 Containers among which i want the 1st Container to be Scrollable and the Second container to be of constant size(Non scrollable) just like whatsapp web ui where contact list keeps scrolling but the chat side and the rest of the page doesn't.
please Help me,
Thanks in advance...
This should work You need a fixed sized container and make sure a Scroll able widget should be inside it. Now size can be made responsive by using Media Query Parameters and below code you only need to adjust space and sizing and it would work.
Row(
//Your parent Row
children: [
Container(
//static non scrollable container
child: Column(
children: [
//Children you want to add
//this wont be scrollable
//It is also preferred that you give this some height or width too
],
),
),
Container(
//Scrollable container
//Please adjust height and width yourself
//You can use media query parameters to make it responsive
width: 200,
height: 500,
child: SingleChildScrollView(
//You can also change the scroll direction
child: Column(
//Add children you want to be in
//Scrollable column
),
),
)
],
),

Flutter collapsed ExpansionTile not saving form data?

I am working on flutter expansionTile and added different fields inside that. If I expand the expansionTile and hit submit, The form fields are submitted which are inside expansionTile. But If I collapse it and then hit submit, then only those fields values are displayed that are not collapsed.
Well for the reference here is a piece of code.
ExpansionTile(
backgroundColor: Theme.of(context)
.accentColor
.withOpacity(0.050),
title: Text(item.formName),
children: <Widget>[
FormBuilderCheckboxList(
decoration:
InputDecoration(labelText: item.formName),
attribute: item.uniqueId,
initialValue: [],
// initialValue: item?.answerMultiple.map( (ans) =>ans )??[],
options: item.formFieldOptions
.map((opt) => FormBuilderFieldOption(
value: opt.optName))
.toList(),
),
],
),
So This if I submit this checkbox field expanded then it shows the values on my DEBUG CONSOLE and if I close the ExpansionTile then its not show me any thing. Below is the output when I have expanded the Tile.
flutter: {uid_201994077147: Yes, uid_201985062316: [• Sodium Chloride – (Road Salt, Table Salt) , • Calcium Chloride , • Ammonium Nitrate , Ammonium Sulfate , Sand]}
Thank you all in advance.
Not sure if you still need this but I experienced the same issue and it seems that default behavior of ExpensionTile is removing all of its children when collapsed. There is a PR in flutter repo waiting to be merged. Until then we need to find a workaround for that. It might be keeping the state whenever value changes or when collapse changes and reinitializing its value when collapse changed again.