Skip to content

Commit

Permalink
Update null safety example for 2.12 (#90)
Browse files Browse the repository at this point in the history
* Update readme and pubspec

* Remove unneeded IDE configs
  • Loading branch information
mit-mit authored Mar 3, 2021
1 parent ee5a1f9 commit 7944dcd
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 225 deletions.
14 changes: 0 additions & 14 deletions null_safety/calculate_lix/.idea/calculate_lix.iml

This file was deleted.

116 changes: 0 additions & 116 deletions null_safety/calculate_lix/.idea/codeStyles/Project.xml

This file was deleted.

8 changes: 0 additions & 8 deletions null_safety/calculate_lix/.idea/modules.xml

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions null_safety/calculate_lix/.vscode/launch.json

This file was deleted.

62 changes: 4 additions & 58 deletions null_safety/calculate_lix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@

This is a small code example of an app that calculates the 'lix' readability
index for a text file. The implementation uses the Dart null safety feature,
and is meant 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 its current tech preview stage.
and is meant to demonstrate how this feature works in a practical example.

## Running the example code
## Supported SDK versions

The code works only with preview builds of null safety from the `beta`
channel. If you're using Flutter, you can run:

```cmd
flutter channel beta
flutter upgrade
```

to switch to this channel; alternatively, you may download and install the
latest null safety preview build of Dart from the [Dart SDK
archive](https://dart.dev/tools/sdk/archive#beta-channel).
The example requires Dart 2.12 or later. If you're using Flutter, you need
Flutter 2.0 or later.

### Running from the terminal / command prompt

Expand All @@ -30,49 +19,6 @@ $ dart pub get
$ dart run bin/main.dart text/lorem-ipsum.txt
```

### Running from VSCode

This example contains a launch configuration for VSCode that runs
`bin/main.dart`, so to run the sample in
VSCode:

1. If you're using a separate copy of Dart, rather than the Flutter `dev`
channel, edit your VSCode configuration to point to one additional Dart
SDK, the preview SDK we just downloaded. See [details
here](https://dartcode.org/docs/quickly-switching-between-sdk-versions/)
for what values to put in **View > Command Palette > Open Settings
(JSON)**.

1. Invoke **File > Open**, and select the `calculate_lix` folder.

1. Tell VSCode to use the preview Dart SDK: Open `bin/main.dart` and then
locate the 'Dart: \<version number\>' selector in the status bar at the
bottom, and select `Dart: 2.12.0-xxx.0.beta` (where `xxx` is the latest
version available.)

1. Select **Run > Run** and the project should run and print a message in the Debug
Console.


### Running from Android Studio

1. Start Android Studio.

1. Select Open Project, and select the `calculate_lix` folder.

1. Open the file `bin/main.dart` in the code editor.

1. Select 'Open Dart Settings' in the top banner.

1. Select both 'Enable Dart support' checkmarks at the top and bottom of the dialog.

1. Under Dart SDK specify the path to the Dart preview SDK
(`2.12.0-xxx.0.beta`, where `xxx` is the latest version available). Click
OK.

1. Select Run > Run and the project should run and print a message in the Run
pane.

## Next steps

Once you have the code running, here some suggestions for things to try:
Expand Down
4 changes: 2 additions & 2 deletions null_safety/calculate_lix/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.15.0"
sdks:
dart: ">=2.12.0-29 <3.0.0"
dart: ">=2.12.0 <3.0.0"
6 changes: 3 additions & 3 deletions null_safety/calculate_lix/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: calculate_lix
description: A command-line application demonstrating use of null safety.
version: 1.2.0
version: 1.3.0

# This example isn't intended for publishing on pub.dev.
publish_to: none

environment:
sdk: '>=2.12.0-29 <3.0.0'
sdk: '>=2.12.0 <3.0.0'

dependencies:
collection: ^1.15.0-nullsafety
collection: ^1.15.0

0 comments on commit 7944dcd

Please sign in to comment.