Skip to content

Instantly share code, notes, and snippets.

@wyattbiker
Last active May 3, 2019 15:04
Show Gist options
  • Save wyattbiker/dc783912f2f92644266e41a699e7504e to your computer and use it in GitHub Desktop.
Save wyattbiker/dc783912f2f92644266e41a699e7504e to your computer and use it in GitHub Desktop.
Example of dartpad code
import 'dart:io';
var x = 4;
class xyz {}
void arrexpr(num n) => (print(n));
void main() {
// print(Platform.pathSeparator);
// print(Platform.operatingSystemVersion);
(arrexpr(10));
dynamic xx = 12;
xx = '123';
print(xx);
var x = 2;
int y = 2;
print(x + y);
abc();
// error because already inferred as int
// x ='abc';
String s1 = 'abc';
var s2 = 'xyz';
print(s1 + s2);
print((s1 + s2).runtimeType);
// Error: A value of type 'String' can't be assigned to a variable of type 'int'.
// s2=1234;
var l1 = [1, 2, 3, 4];
List<int> l2 = <int>[1, 2, 3, 4];
var l3 = <dynamic>[1, 2, 3, 'a', 'b', 'c'];
l1.addAll(l2);
print(l1);
print(l1.runtimeType);
print(l3.runtimeType);
dynamic x4=11;
x4='dddd';
print(x4);
print('THE END');
}
abc() {
var x = 1;
print(x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment