Skip to content

Instantly share code, notes, and snippets.

@JoeCodeswell
Last active July 2, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeCodeswell/cfded55df52dd2bb37228d12c7ef049c to your computer and use it in GitHub Desktop.
Save JoeCodeswell/cfded55df52dd2bb37228d12c7ef049c to your computer and use it in GitHub Desktop.
DartPad Dart List initialization
// on dartpad: https://dartpad.dev/cfded55df52dd2bb37228d12c7ef049c
void main() {
Co co = Co();
print(co.getTag1()); //Out: profitable
print(co.getMgr1().fn); //Out: null
}
class Co {
List<String> _tags = ['profitable', '1999', 'public', 'NYSE'];
String getTag1() {
return _tags.first;
}
List<Mgr> _mgrs = List.from([
Mgr(
fn: 'Janice',
ln: 'Brown',
),
Mgr(
fn: 'Laura',
ln: 'Lopez',
),
Mgr(
fn: 'Linda',
ln: 'Oakley',
),
], growable: false);
Mgr getMgr1(){
return _mgrs.first;
}
}
class Mgr {
String fn;
String ln;
Mgr({String fn, String ln});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment