Dart: spread operator for constructor2019 Community Moderator ElectionCalling the base constructor in C#Virtual member call in a constructorWhat are the rules for calling the superclass constructor?How do I call one constructor from another in Java?Can I call a constructor from another constructor (do constructor chaining) in C++?Call one constructor from anotherDifference between Constructor and ngOnInitHow can I prevent a multi-line Text widget from getting clipped when placed within a Row?How to get constraints like Height and Width of container in flutterHow to set OutlineButton width > child width and the border expand to all available space?

Is "history" a male-biased word ("his+story")?

Straight line with arrows and dots

Playing ONE triplet (not three)

Best approach to update all entries in a list that is paginated?

Do I need to leave some extra space available on the disk which my database log files reside, for log backup operations to successfully occur?

Prove that the total distance is minimised (when travelling across the longest path)

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

Is all copper pipe pretty much the same?

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

Does the Bracer of Flying Daggers benefit from the Dueling fighting style?

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

"One can do his homework in the library"

When is a batch class instantiated when you schedule it?

What is the blue range indicating on this manifold pressure gauge?

Can the druid cantrip Thorn Whip really defeat a water weird this easily?

Is a lawful good "antagonist" effective?

How to deal with a cynical class?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

Is it ok to include an epilogue dedicated to colleagues who passed away in the end of the manuscript?

validation vs test vs training accuracy, which one to compare for claiming overfit?

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

What wound would be of little consequence to a biped but terrible for a quadruped?

How do anti-virus programs start at Windows boot?

Am I not good enough for you?



Dart: spread operator for constructor



2019 Community Moderator ElectionCalling the base constructor in C#Virtual member call in a constructorWhat are the rules for calling the superclass constructor?How do I call one constructor from another in Java?Can I call a constructor from another constructor (do constructor chaining) in C++?Call one constructor from anotherDifference between Constructor and ngOnInitHow can I prevent a multi-line Text widget from getting clipped when placed within a Row?How to get constraints like Height and Width of container in flutterHow to set OutlineButton width > child width and the border expand to all available space?










1















In my flutter app, I have widgets like below:



Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.red,
width: 2,
style: BorderStyle.solid,
),
),
child: Text('Container 1'),
)


Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Colors.red,
width: 2,
style: BorderStyle.solid,
),
),
),
child: Text('Container 2'),
)


Both use the same properties for their borders. So I was wondering if there's a spread-operator-like way of inserting the same properties for both widgets? Maybe like:



const borderBase = (
color: Colors.red,
width: 2,
style: BorderStyle.solid,
)

Container(
decoration: BoxDecoration(
border: Border.all(
...borderBase,
),
),
child: Text('Container 1'),
)

Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
...borderBase,
),
),
),
child: Text('Container 2'),
)









share|improve this question




























    1















    In my flutter app, I have widgets like below:



    Container(
    decoration: BoxDecoration(
    border: Border.all(
    color: Colors.red,
    width: 2,
    style: BorderStyle.solid,
    ),
    ),
    child: Text('Container 1'),
    )


    Container(
    decoration: BoxDecoration(
    border: Border(
    top: BorderSide(
    color: Colors.red,
    width: 2,
    style: BorderStyle.solid,
    ),
    ),
    ),
    child: Text('Container 2'),
    )


    Both use the same properties for their borders. So I was wondering if there's a spread-operator-like way of inserting the same properties for both widgets? Maybe like:



    const borderBase = (
    color: Colors.red,
    width: 2,
    style: BorderStyle.solid,
    )

    Container(
    decoration: BoxDecoration(
    border: Border.all(
    ...borderBase,
    ),
    ),
    child: Text('Container 1'),
    )

    Container(
    decoration: BoxDecoration(
    border: Border(
    top: BorderSide(
    ...borderBase,
    ),
    ),
    ),
    child: Text('Container 2'),
    )









    share|improve this question


























      1












      1








      1








      In my flutter app, I have widgets like below:



      Container(
      decoration: BoxDecoration(
      border: Border.all(
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      ),
      ),
      child: Text('Container 1'),
      )


      Container(
      decoration: BoxDecoration(
      border: Border(
      top: BorderSide(
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      ),
      ),
      ),
      child: Text('Container 2'),
      )


      Both use the same properties for their borders. So I was wondering if there's a spread-operator-like way of inserting the same properties for both widgets? Maybe like:



      const borderBase = (
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      )

      Container(
      decoration: BoxDecoration(
      border: Border.all(
      ...borderBase,
      ),
      ),
      child: Text('Container 1'),
      )

      Container(
      decoration: BoxDecoration(
      border: Border(
      top: BorderSide(
      ...borderBase,
      ),
      ),
      ),
      child: Text('Container 2'),
      )









      share|improve this question
















      In my flutter app, I have widgets like below:



      Container(
      decoration: BoxDecoration(
      border: Border.all(
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      ),
      ),
      child: Text('Container 1'),
      )


      Container(
      decoration: BoxDecoration(
      border: Border(
      top: BorderSide(
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      ),
      ),
      ),
      child: Text('Container 2'),
      )


      Both use the same properties for their borders. So I was wondering if there's a spread-operator-like way of inserting the same properties for both widgets? Maybe like:



      const borderBase = (
      color: Colors.red,
      width: 2,
      style: BorderStyle.solid,
      )

      Container(
      decoration: BoxDecoration(
      border: Border.all(
      ...borderBase,
      ),
      ),
      child: Text('Container 1'),
      )

      Container(
      decoration: BoxDecoration(
      border: Border(
      top: BorderSide(
      ...borderBase,
      ),
      ),
      ),
      child: Text('Container 2'),
      )






      constructor properties dart flutter spread-syntax






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 10:37







      Giraldi

















      asked Mar 7 at 10:34









      GiraldiGiraldi

      12k41937




      12k41937






















          2 Answers
          2






          active

          oldest

          votes


















          2














          You can do something like this:



          const BorderSide borderBase = BorderSide(
          color: Colors.red,
          width: 2,
          style: BorderStyle.solid,
          );

          Container(
          decoration: BoxDecoration(
          border: Border.all(
          color: borderBase.color,
          width: borderBase.width,
          style: borderBase.style,
          ),
          ),
          child: Text('Container 1'),
          )

          Container(
          decoration: BoxDecoration(
          border: Border(
          top: borderBase,
          ),
          ),
          child: Text('Container 2'),
          )


          Not the best but still some reuse.






          share|improve this answer

























          • But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

            – Giraldi
            Mar 7 at 12:15











          • Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

            – Giraldi
            Mar 7 at 12:26







          • 1





            I updated it for you. Tx for the tips!

            – Giraldi
            Mar 7 at 12:28


















          2














          There is no such thing.



          A spread operator is in development, but it is only for lists, not classes (https://github.com/dart-lang/language/issues/47)






          share|improve this answer























          • I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

            – Giraldi
            Mar 7 at 10:38











          • Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

            – Rémi Rousselet
            Mar 7 at 10:47










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55041665%2fdart-spread-operator-for-constructor%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You can do something like this:



          const BorderSide borderBase = BorderSide(
          color: Colors.red,
          width: 2,
          style: BorderStyle.solid,
          );

          Container(
          decoration: BoxDecoration(
          border: Border.all(
          color: borderBase.color,
          width: borderBase.width,
          style: borderBase.style,
          ),
          ),
          child: Text('Container 1'),
          )

          Container(
          decoration: BoxDecoration(
          border: Border(
          top: borderBase,
          ),
          ),
          child: Text('Container 2'),
          )


          Not the best but still some reuse.






          share|improve this answer

























          • But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

            – Giraldi
            Mar 7 at 12:15











          • Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

            – Giraldi
            Mar 7 at 12:26







          • 1





            I updated it for you. Tx for the tips!

            – Giraldi
            Mar 7 at 12:28















          2














          You can do something like this:



          const BorderSide borderBase = BorderSide(
          color: Colors.red,
          width: 2,
          style: BorderStyle.solid,
          );

          Container(
          decoration: BoxDecoration(
          border: Border.all(
          color: borderBase.color,
          width: borderBase.width,
          style: borderBase.style,
          ),
          ),
          child: Text('Container 1'),
          )

          Container(
          decoration: BoxDecoration(
          border: Border(
          top: borderBase,
          ),
          ),
          child: Text('Container 2'),
          )


          Not the best but still some reuse.






          share|improve this answer

























          • But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

            – Giraldi
            Mar 7 at 12:15











          • Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

            – Giraldi
            Mar 7 at 12:26







          • 1





            I updated it for you. Tx for the tips!

            – Giraldi
            Mar 7 at 12:28













          2












          2








          2







          You can do something like this:



          const BorderSide borderBase = BorderSide(
          color: Colors.red,
          width: 2,
          style: BorderStyle.solid,
          );

          Container(
          decoration: BoxDecoration(
          border: Border.all(
          color: borderBase.color,
          width: borderBase.width,
          style: borderBase.style,
          ),
          ),
          child: Text('Container 1'),
          )

          Container(
          decoration: BoxDecoration(
          border: Border(
          top: borderBase,
          ),
          ),
          child: Text('Container 2'),
          )


          Not the best but still some reuse.






          share|improve this answer















          You can do something like this:



          const BorderSide borderBase = BorderSide(
          color: Colors.red,
          width: 2,
          style: BorderStyle.solid,
          );

          Container(
          decoration: BoxDecoration(
          border: Border.all(
          color: borderBase.color,
          width: borderBase.width,
          style: borderBase.style,
          ),
          ),
          child: Text('Container 1'),
          )

          Container(
          decoration: BoxDecoration(
          border: Border(
          top: borderBase,
          ),
          ),
          child: Text('Container 2'),
          )


          Not the best but still some reuse.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 7 at 12:27









          Giraldi

          12k41937




          12k41937










          answered Mar 7 at 10:49









          Daniel PDaniel P

          2,42112834




          2,42112834












          • But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

            – Giraldi
            Mar 7 at 12:15











          • Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

            – Giraldi
            Mar 7 at 12:26







          • 1





            I updated it for you. Tx for the tips!

            – Giraldi
            Mar 7 at 12:28

















          • But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

            – Giraldi
            Mar 7 at 12:15











          • Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

            – Giraldi
            Mar 7 at 12:26







          • 1





            I updated it for you. Tx for the tips!

            – Giraldi
            Mar 7 at 12:28
















          But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

          – Giraldi
          Mar 7 at 12:15





          But this way I get errors in the borderBase variable saying Undefined name 'color', and other linter errors.

          – Giraldi
          Mar 7 at 12:15













          Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

          – Giraldi
          Mar 7 at 12:26






          Oh, I think you meant the borderBase var should use the BorderSide() class, right? Cause that seems to work.

          – Giraldi
          Mar 7 at 12:26





          1




          1





          I updated it for you. Tx for the tips!

          – Giraldi
          Mar 7 at 12:28





          I updated it for you. Tx for the tips!

          – Giraldi
          Mar 7 at 12:28













          2














          There is no such thing.



          A spread operator is in development, but it is only for lists, not classes (https://github.com/dart-lang/language/issues/47)






          share|improve this answer























          • I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

            – Giraldi
            Mar 7 at 10:38











          • Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

            – Rémi Rousselet
            Mar 7 at 10:47















          2














          There is no such thing.



          A spread operator is in development, but it is only for lists, not classes (https://github.com/dart-lang/language/issues/47)






          share|improve this answer























          • I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

            – Giraldi
            Mar 7 at 10:38











          • Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

            – Rémi Rousselet
            Mar 7 at 10:47













          2












          2








          2







          There is no such thing.



          A spread operator is in development, but it is only for lists, not classes (https://github.com/dart-lang/language/issues/47)






          share|improve this answer













          There is no such thing.



          A spread operator is in development, but it is only for lists, not classes (https://github.com/dart-lang/language/issues/47)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 10:36









          Rémi RousseletRémi Rousselet

          33.7k380105




          33.7k380105












          • I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

            – Giraldi
            Mar 7 at 10:38











          • Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

            – Rémi Rousselet
            Mar 7 at 10:47

















          • I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

            – Giraldi
            Mar 7 at 10:38











          • Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

            – Rémi Rousselet
            Mar 7 at 10:47
















          I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

          – Giraldi
          Mar 7 at 10:38





          I see. So ther's no way to re-use the same properties dynamically? Meaning I have to repeat them everytime?

          – Giraldi
          Mar 7 at 10:38













          Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

          – Rémi Rousselet
          Mar 7 at 10:47





          Yes, you're forced to. But you can discuss about it on the issue. I think this is an interesting feature too.

          – Rémi Rousselet
          Mar 7 at 10:47

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55041665%2fdart-spread-operator-for-constructor%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme