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?
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
add a comment |
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
add a comment |
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
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
constructor properties dart flutter spread-syntax
edited Mar 7 at 10:37
Giraldi
asked Mar 7 at 10:34
GiraldiGiraldi
12k41937
12k41937
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
But this way I get errors in theborderBase
variable sayingUndefined name 'color'
, and other linter errors.
– Giraldi
Mar 7 at 12:15
Oh, I think you meant theborderBase
var should use theBorderSide()
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
add a comment |
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)
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
But this way I get errors in theborderBase
variable sayingUndefined name 'color'
, and other linter errors.
– Giraldi
Mar 7 at 12:15
Oh, I think you meant theborderBase
var should use theBorderSide()
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
add a comment |
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.
But this way I get errors in theborderBase
variable sayingUndefined name 'color'
, and other linter errors.
– Giraldi
Mar 7 at 12:15
Oh, I think you meant theborderBase
var should use theBorderSide()
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
add a comment |
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.
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.
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 theborderBase
variable sayingUndefined name 'color'
, and other linter errors.
– Giraldi
Mar 7 at 12:15
Oh, I think you meant theborderBase
var should use theBorderSide()
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
add a comment |
But this way I get errors in theborderBase
variable sayingUndefined name 'color'
, and other linter errors.
– Giraldi
Mar 7 at 12:15
Oh, I think you meant theborderBase
var should use theBorderSide()
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
add a comment |
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)
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
add a comment |
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)
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
add a comment |
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)
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)
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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