Skip to content

Instantly share code, notes, and snippets.

@usimsek
Last active September 19, 2020 20:46
Show Gist options
  • Save usimsek/7b3ed7efd9296e4927967c34a2b3d4cc to your computer and use it in GitHub Desktop.
Save usimsek/7b3ed7efd9296e4927967c34a2b3d4cc to your computer and use it in GitHub Desktop.
flutter convert variable / flutter değişken tipini dönüştürme (tr) / int to string - string to date - string to double vs.
void main(){
var x = "4";
int number = int.parse(x);//STRING to INT
var y = "4.6";
double doubleNum = double.parse(y);//STRING to DOUBLE
var z = 55;
String myStr = z.toString();//INT to STRING
}
// değerin . sonra kaç karakter gösterileceğini sağlar.(toStringAsFixed(2))
Text('\$${cart.totalAmount.toStringAsFixed(2)}'), //2.34
///////////////////init begin
// First add intl package into your pubspec.yaml file, just after flutter sdk:
// Öncelikle flutter sdk'den hemen sonra pubspec.yaml dosyanıza intl paketi ekleyin
print(NumberFormat.currency().format(123456)); // USD123,456.00
print(NumberFormat.currency(locale: 'eu').format(123456)); // 123.456,00 EUR
print(NumberFormat.currency(name: 'EURO').format(123456)); // EURO123,456.00
print(NumberFormat.currency(locale: 'eu', symbol: '?').format(123456)); // 123.456,00 ?
print(NumberFormat.currency(locale: 'eu', decimalDigits: 3).format(123456)); // 123.456,000 EUR
print(NumberFormat.currency(locale: 'eu', customPattern: '\u00a4 #,##.#').format(123456)); // EUR 12.34.56,00
//string gelen bir tarihi formatlama ( "tarih": "2020-02-01T00:00:00")
Text(DateFormat("dd/MM/yyyy").format(DateTime.parse(item.tarih)),), // (01.02.2020)
//////////////////////////init end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment