Skip to content

Instantly share code, notes, and snippets.

@vraj6198
Created April 15, 2019 17:01
Show Gist options
  • Save vraj6198/4f2fc25a7167e0f6164b546528b08bb3 to your computer and use it in GitHub Desktop.
Save vraj6198/4f2fc25a7167e0f6164b546528b08bb3 to your computer and use it in GitHub Desktop.
The Dart language has special support for the following types:
numbers
strings
booleans
lists (also known as arrays)
sets
maps
runes (for expressing Unicode characters in a string)
symbols
every variable in Dart refers to an object—an instance of a class—you can usually use constructors to initialize variables.
Some of the built-in types have their own constructors. For example, you can use the Map() constructor to create a map.
int
Integer values no larger than 64 bits.
double
64-bit (double-precision) floating-point numbers.
Both int and double are subtypes of num. The num type includes basic operators such as +, -, /, and *, and is also where you’ll find abs(), ceil(), and floor(), among other methods.
// String -> int
var one = int.parse('1');
assert(one == 1);
// String -> double
var onePointOne = double.parse('1.1');
assert(onePointOne == 1.1);
// int -> String
String oneAsString = 1.toString();
assert(oneAsString == '1');
// double -> String
String piAsString = 3.14159.toStringAsFixed(2);
assert(piAsString == '3.14');
print(one);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment