Guest User

Untitled

a guest
Dec 12th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. //a statefull widget receive it values directly from the constructor,
  2. //from doc : A widget that does not require mutable state.
  3. class MyWidget extends StateFullWidget {
  4.  
  5. //final == val (kotlin)
  6. final _myText = "";
  7.  
  8. //default constructor, braces {} means the arguments can be provided in any order
  9. //_myText = text means _myText is initialised with the `text` value automatically
  10. MyWidget({this.key, @required String text}) : _myText = text;
  11.  
  12. @override
  13. Widget build(BuildContext context) { //BuildContext => represents the parent widget
  14. var imageUrl = "www.mywebsites.com/${_myText}";
  15. return GestureDetector( //add user interraction
  16. onTap: () { //lambdas without parameter, like kotlin
  17. print("tapped");
  18. },
  19. child: Row( //Row == Vertical LinearLayout
  20. children: [
  21. //download then display an image
  22. Image.network(imageUrl),
  23. Text(_myText)
  24. ]
  25. )
  26. )
  27. }
  28. }
Add Comment
Please, Sign In to add comment