Skip to content

Instantly share code, notes, and snippets.

@florent37
Last active December 13, 2018 07:49
Show Gist options
  • Select an option

  • Save florent37/e5ca77e8d6891d1925f662d104c632c4 to your computer and use it in GitHub Desktop.

Select an option

Save florent37/e5ca77e8d6891d1925f662d104c632c4 to your computer and use it in GitHub Desktop.

Revisions

  1. florent37 revised this gist Dec 13, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    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
  2. florent37 revised this gist Dec 12, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ class MyWidget extends StateFullWidget {
    @override
    Widget build(BuildContext context) { //BuildContext => represents the parent widget
    var imageUrl = "www.mywebsites.com/${_myText}";
    return GestureDetector(
    return GestureDetector( //add user interraction
    onTap: () { //lambdas without parameter, like kotlin
    print("tapped");
    },
  3. florent37 revised this gist Dec 12, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    //a statefull widget receive it values directly from the constructor,
    //here the method build is called once
    //from doc : A widget that does not require mutable state.
    class MyWidget extends StateFullWidget {

    //final == val
    //final == val (kotlin)
    final _myText = "";

    //default constructor, braces {} means the arguments can be provided in any order
  4. florent37 revised this gist Dec 12, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,7 @@ class MyWidget extends StateFullWidget {
    },
    child: Row( //Row == Vertical LinearLayout
    children: [
    //download then display an image
    Image.network(imageUrl),
    Text(_myText)
    ]
  5. florent37 revised this gist Dec 12, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ class MyWidget extends StateFullWidget {
    MyWidget({this.key, @required String text}) : _myText = text;

    @override
    Widget build(BuildContext context) { //BuildContext => the current position on the widget trees + its parent's size
    Widget build(BuildContext context) { //BuildContext => represents the parent widget
    var imageUrl = "www.mywebsites.com/${_myText}";
    return GestureDetector(
    onTap: () { //lambdas without parameter, like kotlin
  6. florent37 revised this gist Dec 12, 2018. 1 changed file with 10 additions and 5 deletions.
    15 changes: 10 additions & 5 deletions MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,23 @@
    //a statefull widget receive it values directly from the constructor,
    //here the method build is called once
    class MyWidget extends StateFullWidget {

    //final == val
    final _myText = "";

    MyWidget({this.key, String text}) : _myText = text;
    //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) {
    Widget build(BuildContext context) { //BuildContext => the current position on the widget trees + its parent's size
    var imageUrl = "www.mywebsites.com/${_myText}";
    return GestureDetector(
    onTap: () {
    onTap: () { //lambdas without parameter, like kotlin
    print("tapped");
    },
    child: Row(
    children: [
    child: Row( //Row == Vertical LinearLayout
    children: [
    Image.network(imageUrl),
    Text(_myText)
    ]
  7. florent37 created this gist Dec 12, 2018.
    22 changes: 22 additions & 0 deletions MyWidget.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    class MyWidget extends StateFullWidget {

    final _myText = "";

    MyWidget({this.key, String text}) : _myText = text;

    @override
    Widget build(BuildContext context) {
    var imageUrl = "www.mywebsites.com/${_myText}";
    return GestureDetector(
    onTap: () {
    print("tapped");
    },
    child: Row(
    children: [
    Image.network(imageUrl),
    Text(_myText)
    ]
    )
    )
    }
    }