Created
March 12, 2020 20:06
-
-
Save samuelematias/a2ab7476f206982af65f11a964d0555b to your computer and use it in GitHub Desktop.
Examples of Dart extension methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Paddings on Widget { | |
Widget paddingAll(double padding) => Padding( | |
padding: EdgeInsets.all(padding), | |
child: this, | |
); | |
} | |
extension TextStyles on Text { | |
Text h1() { | |
if (this is Text) { | |
final Text t = this; | |
return Text( | |
t.data, | |
style: TextStyle( | |
color: Colors.black, | |
fontWeight: FontWeight.w600, | |
fontSize: 50.0, | |
fontFamily: merriweather, | |
), | |
); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment