Thứ Năm, 12 tháng 11, 2020

How to change icon color in flutter

 @override

Widget build(BuildContext context) {
  return new Scaffold(
    drawer: new Drawer(),
    appBar: new AppBar(
      title: new Text("Navigation Drawer"),
      iconTheme: new IconThemeData(color: Colors.green),
    ),
  );
}

Chủ Nhật, 2 tháng 8, 2020

How to add lib from github in flutter

dependencies:
  flutter:
    sdk: flutter

  carousel_pro:
    git:
      url: git://github.com/jlouage/flutter-carousel-pro.git
      ref: master

Thứ Ba, 28 tháng 7, 2020

how to change double to int flutter

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ứ Tư, 10 tháng 6, 2020

how to hide keyboad in flutter

FocusScope.of(context).requestFocus(FocusNode());

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

// get time current
var today = new DateTime.now();
// add time var fiftyDaysFromNow = today.add(new Duration(days: 50));
// get timezome
var timezoneOffset = now.timeZoneOffset;

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

Thứ Tư, 27 tháng 11, 2019

Upload anh bang POST in flutter

static dynamic upImage(File imageFile) async {
  var stream = new http.ByteStream(DelegatingStream.typed(imageFile.openRead()));  var length = await imageFile.length();  final String token = await constants.getToken();  var uri = Uri.parse(apiupload);
  Map<String, String> headers = {
    'se-client': "api",    'se-api-key': "f50949f7a35a3b0d46b08abd20bead1d:hd2OQtdb5Z9SCx5OAF7iKi97G8PsBJbX9YjIbYVHufDo4nVCycsJHvmPoXuRfVgv",    'se-viewer-token': token
  };  Map<String, String> body = {
    'typeId': 'image',    'productId': '@SE/Media',  };  var multipartFile = new http.MultipartFile('file', stream, length,filename: basename( imageFile.path));
  var request = new http.MultipartRequest("POST", uri);  request.headers.addAll(headers);  request.fields.addAll(body);  request.files.add(multipartFile);
  var response = await request.send();  return  await response.stream.bytesToString();}

Thứ Ba, 19 tháng 11, 2019

Nhìu định dạng chữ trong cùng 1 dòng in flutter

Text.rich(
  TextSpan(
    text: 'Hello ',
    style: TextStyle(fontSize: 50),
    children: <TextSpan>[
      TextSpan(
          text: 'world',
          style: TextStyle(
            decoration: TextDecoration.underline,
          )),
      // can add more TextSpans here...
    ],
  ),
)

How to reload app in flutter

  Phoenix . rebirth (context);