Skip to content

Instantly share code, notes, and snippets.

@florent37
Last active Dec 13, 2018
Embed
What would you like to do?
//a statefull widget receive it values directly from the constructor,
//from doc : A widget that does not require mutable state.
class MyWidget extends StateFullWidget {
//final == val (kotlin)
//underscore _ means private in dart
final _myText = "";
//default constructor, braces {} means the arguments can be provided in any order
//_myText = text means _myText is initialised with the `text` value automatically
MyWidget({this.key, @required String text}) : _myText = text;
@override
Widget build(BuildContext context) { //BuildContext => represents the parent widget
var imageUrl = "www.mywebsites.com/${_myText}";
return GestureDetector( //add user interraction
onTap: () { //lambdas without parameter, like kotlin
print("tapped");
},
child: Row( //Row == Vertical LinearLayout
children: [
//download then display an image
Image.network(imageUrl),
Text(_myText)
]
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment