Skip to content

Instantly share code, notes, and snippets.

@florent37
Last active December 13, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florent37/e5ca77e8d6891d1925f662d104c632c4 to your computer and use it in GitHub Desktop.
Save florent37/e5ca77e8d6891d1925f662d104c632c4 to your computer and use it in GitHub Desktop.
//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