double d = 20.5;
int i = d.toInt(); // i = 20
int i = d.round(); // i = 21
int i = d.ceil(); // i = 21
int i = d.floor(); // i = 20
Thứ Ba, 28 tháng 7, 2020
how to change double to int flutter
Thứ Năm, 11 tháng 6, 2020
Thứ Tư, 10 tháng 6, 2020
How to set timeout when connect api in flutter
try {
final request = await client.get(...);
final response = await request.close()
.timeout(const Duration(seconds: 2));
// rest of the code
...
} on TimeoutException catch (_) {
// A timeout occurred.
} on SocketException catch (_) {
// Other exception
}
Thứ Ba, 9 tháng 6, 2020
How to Get/set in flutter
class Foo { String bar; // normal field (getter/setter) final String baz; // read-only (getter) int _weight; set weight(int value) { assert(weight >= 0); _weight = value; } int get weight => _weight }
Thứ Hai, 8 tháng 6, 2020
Thứ Năm, 4 tháng 6, 2020
Fomat number in flutter
final formatter = new NumberFormat("#,###");
new Text(formatter.format(1234)), // formatted number will be: 1,234
Đăng ký:
Bài đăng (Atom)
How to reload app in flutter
Phoenix . rebirth (context);
-
final formatter = new NumberFormat ( "#,###" ); new Text ( formatter . format ( 1234 )), // formatted number will be: 1,234 ...
-
try { final request = await client . get (...); final response = await request . close () . timeout ( const Duration ( se...
-
Wrap( children: [ MyWidget(), MyWidget(), MyWidget(), MyWidget(), MyWidget(), ], ),