Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Updating tutorial samples to Dart v2 #49

Merged
merged 26 commits into from
Jul 2, 2019

Conversation

domesticmouse
Copy link
Contributor

No description provided.

@domesticmouse
Copy link
Contributor Author

PTAL @kwalrath @legalcodes

Copy link
Contributor

@kevmoo kevmoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks like a big improvement.

build_web_compilers: ^1.0.0
pedantic: ^1.7.0

homepage: https://dart.dev/tutorials/web/low-level-html/add-elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this above dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


executables:
dcat:
dgrep:

homepage: https://www.dartlang.org/tutorials/server/cmdline
homepage: https://dart.dev/tutorials/server/cmdline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move towards top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


dev_dependencies:
build_runner: ^1.1.2
build_web_compilers: ^1.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch to ^2.0.0?

Copy link
Contributor Author

@domesticmouse domesticmouse Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, and as this was all based on Stagehand, I updated Stagehand's templates as well.

dart-archive/stagehand#614

@@ -5,37 +5,42 @@
import 'dart:html';
import 'dart:async';

DivElement output = querySelector('#output');
PreElement pre = PreElement();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Don't need a type on the left.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// Imagine that this function is more complex and slow. :)
Future gatherNewsReports() async {
String path = 'https://www.dartlang.org/f/dailyNewsDigest.txt';
String path = 'https://dart.dev/f/dailyNewsDigest.txt';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Future expensiveA() => new Future.value('from expensiveA');
Future expensiveB() => new Future.value('from expensiveB');
Future expensiveC() => new Future.value('from expensiveC');
Future expensiveA() => Future.value('from expensiveA');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about Future<String> return type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:html';

void main() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is cleaner to do with async and await, but this directory of samples seems to be all about using Futures API.

@@ -11,15 +11,17 @@
import 'dart:async';
import 'dart:io';
import 'package:http_server/http_server.dart';
import 'package:path/path.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we import this as p;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@domesticmouse
Copy link
Contributor Author

@kevmoo do you want to merge this as is, or wait until @kwalrath gets back?

@kevmoo
Copy link
Contributor

kevmoo commented Jun 21, 2019

@kevmoo do you want to merge this as is, or wait until @kwalrath gets back?

Probably best to wait until she gets back.

@domesticmouse
Copy link
Contributor Author

PTAL @kwalrath, now that you are back =)

Copy link
Contributor

@kwalrath kwalrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like not all of these improvements are in the doc. E.g. https://dart.dev/tutorials/server/cmdline has int lineNumber = 1.

Unfortunately, I don’t know/remember whether there’s an automatic way to update the code, especially since it’s highlighted. We might just have to eyeball it. I’ll file an issue reminding us to do this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

5 participants