Skip to content

Instantly share code, notes, and snippets.

@juliuscanute
Last active August 10, 2019 08:33
Show Gist options
  • Save juliuscanute/b2842a0d2e519b17571d6b24c99d43c5 to your computer and use it in GitHub Desktop.
Save juliuscanute/b2842a0d2e519b17571d6b24c99d43c5 to your computer and use it in GitHub Desktop.
[Creating a constructor within a class] #dart #class #constructor
const $1({p1,p2,...,pn}): assert(condition(p1)),super(p1);
//$1 - Enclosing Class Name.
//p1...pn - Parameters to pass to the constructor.
const MyWidget({Key key,
@required this.name,
@required this.color,
@required this.iconLocation,
}) : assert(name != null),
assert(color != null),
assert(iconLocation != null),
super(key: key);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment