question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ternary operators not being formatted like they are in the widgets in VS Code

See original GitHub issue

Steps to Reproduce

I have a getter in my model, in model.dart that (intelliJ I guess) formats like this: Captura de pantalla 2020-05-11 a las 22 23 33 instead of like this: Captura de pantalla 2020-05-11 a las 22 29 12

Expected results: IntelliJ formats nested ternary operators well in my widgets. Like this example in my main_screen.dart Captura de pantalla 2020-05-11 a las 22 25 44

Actual results:

Logs
[✓] Flutter (Channel master, 1.19.0-0.0.pre, on Mac OS X 10.15.4 19E287, locale es-ES)
    • Flutter version 1.19.0-0.0.pre at /Users/tomas/Developer/flutter
    • Framework revision 053c38818f (4 days ago), 2020-05-07 15:22:03 -0700
    • Engine revision 3953c3ccd1
    • Dart version 2.9.0 (build 2.9.0-5.0.dev 4da5b40fb6)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/tomas/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.10.1

[✓] Connected device (3 available)
    • iPhone 11 Pro • A85E0A78-987E-41EA-9676-E33AC01D746D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
    • Web Server    • web-server                           • web-javascript • Flutter Tools
    • Chrome        • chrome                               • web-javascript • Google Chrome 81.0.4044.138

• No issues found!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, May 13, 2020

I was rather talking about were situations when having nested ternary operators.

Oh sorry, I see what you mean. Based on the text in the FAQ it may be worth filing an issue at dart_style for their take on it, it may be considered a reasonable change.

0reactions
tomasbarancommented, May 13, 2020

I just reported it there: https://github.com/dart-lang/dart_style/issues/927

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

I am getting an error while writing a ternary operator under a ...
I am getting this error The element type 'Set' can't be assigned to the list type 'Widget' How do I fix this? flutter...
Read more >
Ternary format bug - Visual Studio Feedback
When writing the code std::string {} + (true ? "yes" : "no"); , and selecting the line before pressing Ctrl+K, Ctrl+F (Edit.FormatSelection), VS...
Read more >
Flutter Tutorial for Beginners #33 -Ternary Operators - YouTube
Hey gang, in this Flutter tutorial we'll see how to use a ternary operator in Dart to choose what background image to show...
Read more >
Curious Perversions in Information Technology - The Daily WTF
Yup, the real problem here was common subexpressions, not the ternary operator. I consider duplicated code to be the worst enemy of clarity....
Read more >
Ternary Operator in Python - GeeksforGeeks
Ternary operators are also known as conditional expressions are operators that evaluate something based on a condition being true or false.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found