1

As the title states, I'd like to do something like this in dart/flutter:

bool someBool = true;
double pad = 10.5;
double left, right = someBool ? (padd / 4, padd) : (padd, padd / 4);

Is there a way to achieve this as a one liner in dart, or do I really have to resort to the following:

bool someBool = true;
double pad = 10.5;
double left = someBool ? padd / 4 : padd;
double right = someBool ? padd : padd / 4;

Thanks!

1
  • you need two assignments, sorry Commented Mar 7, 2020 at 14:22

1 Answer 1

1

You will need to use two ternary operators:

double left = someBool ? pad / 4 : pad, right = someBool ? pad : pad / 4;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.