flutter create --org com.name-of-project-or-what-ever name-of-project
ListView.builder() {
itemBuilder: (ctx, index) {
// return Card? Column?
return Card(
child: // .... do something here
)
},
itemCount: // length of data want to loop E.g array.length
}
make DateTime type to String int package
import 'package:intl/intl.dart';
DateFormat.yMMMD().format("DATE_HERE")
//May 19, 2020
final stateForTitle = TextEditingController()
final stateForBody = TextEditingController()
// usage
TextFormFiled(
controller: stateForTitle,
decoration: InputDecoration(
labelText: "Title"
),
)
final _formKey = GlobalKey<FormState>();
// usage
Form(
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 button
FlatButton(
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
}
)
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)
]
})
import 'package:flutter/foundation.dart';
class Transaction {
final String id;
final String title;
final double amount;
final DateTime date;
Transaction({
@required this.id,
@required this.title,
@required this.amount,
@required this.date
});
}
List<Map<String, Object>> // [ {name: "heheh"}]
List<Car> // [ { name: "toyota"}]
String
double
DateTime
Container(
decoration: BoxDecoration(
color: Colors.amber,
shape: BoxShape.circle
),
width: "NUMBER",
height: "NUMBER",
)
// promise
void _presentDatePickerModal() {
showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2019),
lastDate: DateTime.now(),
).then((pickedDateByUser) {
// do something here
})
}
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 methods
Navigator.of(context).pop();
// if your modal covered by keyboard, wrap your modal / form with this widget below
SingleChildScrollView()
Container(
height: (MediaQuery.of(context).size.height - appBar.preferredsize.height() -MediaQuery.of(context).padding.top) * "NUMBER_YOU_WANT",
)
// text scale
final curScaleFactor = MediaQuery.of(context).textScaleFactor;
Text('This changes!', style: TextStyle(fontSize: 20 * curScaleFactor));
// this builder is to gets parent size
LayoutBuilder(builder: (ctx, constrains){
Container(
height: constrains.maxHeight * 0.7, // 7%
width: 10,
child: // child widgets here
)
})
final isLandscape = MediaQuery.of(context).orientation == Orientation.landscape;
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => nameWidgetForThisRoute(propHere: "text_here")
)
);
Navigator.pushNamed(context, ‘/routingName’);
Navigator.pushReplaceNames(context, “/nameRoute”, arguments : payload);