Skip to content

Instantly share code, notes, and snippets.

@indatawetrust
Created May 25, 2018 18:52
Show Gist options
  • Select an option

  • Save indatawetrust/4b26aaf3279f2f9798ec63878f39ac53 to your computer and use it in GitHub Desktop.

Select an option

Save indatawetrust/4b26aaf3279f2f9798ec63878f39ac53 to your computer and use it in GitHub Desktop.
widget usage with parameter
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