Skip to content

Instantly share code, notes, and snippets.

extension NumberParsing on String {
int parseInt() {
return int.parse(this);
}
double parseDouble() {
return double.parse(this);
}
}
Text("Plain TextField:$_field1text"),
TextField(
onChanged: (text) {
setState(() {
_field1text = text;
});
},
)
TextField(
cursorColor: Colors.red,
cursorWidth: 4.0,
maxLength: 10,
obscureText: true,
onChanged: (text) {
print(text);
},
onSubmitted: (text) {
print('Submitted:$text');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('DataTable Demo'),
),
body: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
child: _getDataTable(),
List<String> csvRows;
List<String> csvHeadingRow;
@override
void initState() {
super.initState();
List<String> csvSplit = widget.csvString.split('\n');
csvHeadingRow = csvSplit[0].split(',');
csvSplit.removeAt(0);
csvRows = csvSplit;
DataTable(
columns: [
DataColumn(label: Text('A')),
DataColumn(label: Text('B')),
],
rows: [
DataRow(
cells: [
DataCell(Text('A1')),
DataCell(Text('B1')),
DragTarget(
builder: (context, List<FlutterLogoColor> candidateData, rejectedData) {
return Container(
height: 50.0,
width: 50.0,
decoration: BoxDecoration(
color: Colors.yellow[600],
shape: BoxShape.circle
),
child: Icon(Icons.delete, size: 40, color: Colors.white70,),
Draggable(
child: FlutterLogo(size: 50.0, colors: Colors.red,),
feedback: FlutterLogo(size: 50.0, colors: Colors.red,),
childWhenDragging: FlutterLogo(colors: Colors.blueGrey, size: 50.0,),
data: FlutterLogoColor.red,
)
void future_dowhile() {
final nums = [1, 2, 3, 4, 5];
var sum = 0;
var count = 0;
Future.doWhile(() {
print('count:$count');
if (count == nums.length) {
return false;
} else {
void future_wait(String url1, String url2) {
Future.wait([
http.get(url1),
http.get(url2),
Future.error('Future.error()'),
],
cleanUp: (value) { print('CleanUp() : ${value?.statusCode}'); }
).then((value) {
for (var f in value) {
print('statusCode: ${f?.statusCode}');