This is a small code example of an app that calculates the 'lix' readability index for a text file. The implementation uses the new Dart null safety feature, and is means to demonstrate how this feature works in a practical example, as-well-as serve as a demonstration of how to configure and run code with null safety at it's current technical preview stage.
The code example only works with the null safety technical preview 1 build, Dart
SDK version 2.9.0-11.0.dev
. You will need to download a copy of this Dart SDK
even if you have a Flutter or Dart SDK installed already, and you want to use
this preview SDK only for experimenting with null safety. Specifically, do not
use it for any kind of production coding.
-
Unzip the SDK to a folder, e.g.
/Users/michael/dev/preview/dart-sdk
orC:\Users\michael\dev\preview\dart-sdk\
Because null safety is still in technical preview, we need to pass a so-called
'experiment flag' when invoking and Dart command in the terminal, which looks
like this: --enable-experiment=non-nullable
.
To run the main app, type these commands in the terminal/command-prompt:
- Windows:
cd <the folder that contains this code example>
C:\Users\michael\dev\preview\dart-sdk\bin\dart --enable-experiment=non-nullable bin\main.dart text\lorem-ipsum.txt
- macOS/Linux:
cd <the folder that contains this code example>
/Users/michael/dev/preview/dart-sdk/bin/dart --enable-experiment=non-nullable bin/main.dart text/lorem-ipsum.txt
TODO
TODO