Created
May 25, 2018 18:52
-
-
Save indatawetrust/4b26aaf3279f2f9798ec63878f39ac53 to your computer and use it in GitHub Desktop.
widget usage with parameter
This file contains hidden or 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
| class HeaderNameWidget extends StatefulWidget { | |
| HeaderNameWidget({Key key, this.name}) : super(key: key); | |
| final String name; | |
| @override | |
| _HeaderNameState createState() => new _HeaderNameState(); | |
| } | |
| class _HeaderNameState extends State<HeaderNameWidget> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return new Expanded( | |
| child: new Center( | |
| child: new RichText( | |
| text: new TextSpan( | |
| // Note: Styles for TextSpans must be explicitly defined. | |
| // Child text spans will inherit styles from parent | |
| style: new TextStyle( | |
| fontSize: 22.0, | |
| color: Colors.black, | |
| ), | |
| children: <TextSpan>[ | |
| new TextSpan( | |
| text: widget.name, | |
| style: new TextStyle(fontWeight: FontWeight.bold)), | |
| ], | |
| ), | |
| ))); | |
| } | |
| } | |
| new HeaderNameWidget(name: "Ahmet"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment