You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final stateForTitle =TextEditingController()
final stateForBody =TextEditingController()
// usage TextFormFiled(
controller: stateForTitle,
decoration:InputDecoration(
labelText:"Title"
),
)
how to make validate in form
final _formKey =GlobalKey<FormState>();
// usageForm(
key: _formKey
)
TextFormFiled(
keyboardType:TextInputType.numberWithOptions(decimal:true), // for strict data type
validator: (value) {
return value.isEmpty ?"Required field":null;
}
)
// before we click; that _formKey work like this on buttonFlatButton(
onPressed: () {
if(_formKey.currentState.validate()) {
// do something if the field not empty or whatever you want to validate in validator
}
// if condition wrong, the "Required field" will be showing on below input form
}
)
Space around Column widget
SizedBox(height:10),
// if you want responsive use LayoutBuilder LayoutBuilder(builder: (ctx, constrains){
Column:Widget<> [
Text("Some Text Here"),
SizedBox(height: constrains.maxHeight *0.05)
]
})
// promisevoid_presentDatePickerModal() {
showDatePicker(
context: context,
initialDate:DateTime.now(),
firstDate:DateTime(2019),
lastDate:DateTime.now(),
).then((pickedDateByUser) {
// do something here
})
}
Show Modal
showModalBottomSheet(
context: ctx,
builder: (_) =>GestureDetector(
onTap: () {},
child:// your widget form or what ever here,
behavior:HitTestBehavior.opaque,
)
);
// close the modal when u click the submit NOTE: call this on your methodsNavigator.of(context).pop();
Modal size Error
// if your modal covered by keyboard, wrap your modal / form with this widget belowSingleChildScrollView()
Responsive
MediaQuery for responsive
Container(
height: (MediaQuery.of(context).size.height - appBar.preferredsize.height() -MediaQuery.of(context).padding.top) *"NUMBER_YOU_WANT",
)
// text scalefinal curScaleFactor =MediaQuery.of(context).textScaleFactor;
Text('This changes!', style:TextStyle(fontSize:20* curScaleFactor));
// this builder is to gets parent sizeLayoutBuilder(builder: (ctx, constrains){
Container(
height: constrains.maxHeight *0.7, // 7%
width:10,
child:// child widgets here
)
})
Get Orientation Landscape or Potrait
final isLandscape =MediaQuery.of(context).orientation ==Orientation.landscape;