dart_style
language
Our great sponsors
dart_style | language | |
---|---|---|
14 | 146 | |
629 | 2,537 | |
1.0% | 1.4% | |
9.2 | 8.9 | |
14 days ago | 7 days ago | |
Dart | TeX | |
BSD 3-clause "New" or "Revised" License | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
dart_style
-
Why is Prettier rock solid?
> Oh I'm curious why you're rewriting it?
The primary driver is that we're moving to a fairly different formatting style: https://github.com/dart-lang/dart_style/issues/1253
The formatter works sort of like a compiler in that it parses the code, translates it to an internal representation, does optimization on that IR, and then outputs final code. The main difference is that the "final code" is also source code, and the "optimization" is line splitting.
The old IR grew organically over time and got increasingly difficult to work with. It baked certain formatting choices directly into the IR (mainly indentation) which line splitting then had no control over. For example, given a function call like:
someLongFunctionName(some + long + argument + expression, [firstElement, anotherElement, aThirdElement]);
-
The Record type is coming to Dart/Flutter!
in your analysis_options.yaml. The formatter doesn't understand the new syntax yet, though.
-
Linter actually that important for a lot of minor things?
Sorry, perhaps im not quite familiar with the GitHub issues you’re chatting about, but a quick search shows the Dart team actually made a very similar argument about laptops and diffs as the first reply in a thread about the 80 character max: https://github.com/dart-lang/dart_style/issues/833
-
What is the best flutter formatter?
Nope, but there is a proposal to set line length in pubspec.yaml: https://github.com/dart-lang/dart_style/issues/918
- Imagine that someone passed a law—literally a criminal offense—if you formatted your code longer than 80 columns. You were forced to comply. Do you honestly believe that your engineering productivity or overall quality of life as a human on Earth would be measurably negatively impacted?
-
Custom Formatting in VS Code
The standard Dart extension only supports formatting using the SDK-supplied formatter (dart_style) which (by design) is not configurable (although it can be turned on/off with the dart.enableSdkFormatter setting).
-
10 Best Visual Studio Code Extensions for Flutter Development
Flutter itself provides formatting choices, however, it only formats Dart files and it doesn’t re-order the code. Flutter formats the code based on these formatting rules.
- Flutter’s take on the 2-space indent code style
-
Anyone else seeing dartfmt hanging VSCode lately?
There are some other possibilities - such as complex code being slow to format (for example I hit https://github.com/dart-lang/dart_style/issues/1022 and originally thought it was a repro for this issue), or that the server is busy doing its initial synchronous scan of the workspace, though those should be temporary and the format should eventually complete so it's probably not what most people are reporting here.
language
- Why do we have to put the const keyword in Flutter?
-
Playing around with Extension Types
I noticed that I can enable inline-class as an experiment to play with Extension Types. You need to also add sdk: ^3.3.0-0 to your pubspec.yaml.
- Entendendo Algoritmos: Recursão
-
Dart 3.1 and a retrospective on functional style programming in Dart
Current syntax is not all that bad if you are going to do OO and add various helper methods on `Message` and its subclasses, but if you just want to define your data and no behavior / helpers - then it is exceedingly verbose.
-
Macro example for Flutter widgets
Reference
-
HTML template languages?
A future version of Dart will probably support macros which should make this all a bit easier to use, similar to how Swift 5.9 works which makes already fantastic use of its new macro capabilities by integrating mobx (or solidjs) like reactivity into SwiftUI by a harmlessly looking @Obervable annotation.
-
What’s New in Swift 5.9?
Coming from a Dart context here where that team is also looking at adding Macros to the language. It was really interesting to compare and contrast some of the approaches https://github.com/dart-lang/language/blob/main/working/macr...
-
Build clean & concise UI components with Flutter similar to styled-components in React Native
Yes, that needs a bit of boilerplate for the constructor declaration and the extra build method, but I personally don't mind and with implicit constructors this will become much easier. Also, you get a performant UI as Flutter knows to not redraw widgets that didn't change.
-
A Guide to State Management in Flutter | Mobile App Development
I know that it would be nice not to use the generator at all, but we have to wait until static metaprogramming is implemented in dart. https://github.com/dart-lang/language/issues/1482
-
Why is Swift so slow (timeout) in compiling this code?
I implemented a prototype version of the algorithm in that paper when exploring exhaustiveness checking for pattern matching in Dart.
I found it pretty easy to understand, but also really easy to get it to generate huge combinatorially large spaces. Some careful memoization and deduplication helped, but even so I never got the performance to a state I considered acceptable.
Instead, I went with Luc Maranget's classic approach and figured out a way to adapt it to a language with subtyping (with a ton of work from Johnni Winther to figure out all of the hard complex cases around generics):
https://github.com/dart-lang/language/blob/main/accepted/fut...
The performance (in the prototype!) was dramatically better. You can always make pattern matching go combinatorial, but I haven't seen any real-world switches get particularly slow with our approach yet, and we have some fairly large tests of matching on tuples of enums.
What are some alternatives?
dart-code-metrics - Software analytics tool that helps developers analyse and improve software quality.
sdk - The Dart SDK, including the VM, dart2js, core libraries, and more.
Dart-Code - Dart and Flutter support for VS Code
freezed - Code generation for immutable classes that has a simple syntax/API without compromising on the features.
flutter-examples - This repository contains the Syncfusion Flutter UI widgets examples and the guide to use them.
quicktype - Generate types and converters from JSON, Schema, and GraphQL
markdownlint - A Node.js style checker and lint tool for Markdown/CommonMark files.
Flutter - Flutter makes it easy and fast to build beautiful apps for mobile and beyond
pub-dev - The pub.dev website
gallery - Flutter Gallery was a resource to help developers evaluate and use Flutter
conduit - Dart HTTP server framework for building REST APIs. Includes PostgreSQL ORM and OAuth2 provider.