-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library tour example tests for dart:io, dart:convert, dart:mirrors #445
Conversation
Contributes to dart-lang#407 and dart-lang#416. Continuation of dart-lang#443
3d98378
to
6da2adc
Compare
{% prettify dart %} | ||
var p = new Person('Bob', 'Smith', 42); | ||
InstanceMirror mirror = reflect(p); | ||
|
||
mirror.invoke(#greet, ['Shailen']); | ||
mirror.invoke(#greet, ['Sundar']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, this change was copied from
site-www/examples/library_tour/mirrors/bin/main.dart
Lines 80 to 81 in 792c517
// Invoke a method on the object. | |
mirror.invoke(#greet, ['Sundar']); |
}); | ||
}{% endprettify %} | ||
} | ||
{% endprettify %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, the updates from the code example above are from https://github.com/dart-lang/site-www/blob/master/examples/library_tour/mirrors/bin/main.dart
0xae, 0xc3, 0xb6, 0xc3, 0xb1, 0xc3, 0xa5, 0xc4, | ||
0xbc, 0xc3, 0xae, 0xc5, 0xbe, 0xc3, 0xa5, 0xc5, | ||
0xa3, 0xc3, 0xae, 0xe1, 0xbb, 0x9d, 0xc3, 0xb1 | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to repeat this long array. In the page it is displayed just a few lines above in the previous excerpt.
89c9481
to
b247239
Compare
b247239
to
d6895c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor comments
@@ -1,8 +1,9 @@ | |||
// ignore_for_file: unused_element, type_annotate_public_apis | |||
// #docplaster | |||
import 'package:test/test.dart'; | |||
// import 'package:test/test.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the changes to this file. Do you want to delete the file instead? Or add a comment explaining why it exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a template file I've been using when creating new test files. I've removed it.
|
||
<div class="alert alert-warning" markdown="1"> | ||
**Important:** | ||
Only command-line scripts and servers can import and use `dart:io`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Flutter apps can also import dart:io.
https://docs.flutter.io/flutter/dart-io/dart-io-library.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added "Flutter mobile apps" to the "only" list.
{% prettify dart %} | ||
import 'dart:mirrors'; | ||
{% endprettify %} | ||
|
||
<div class="alert alert-warning" markdown="1"> | ||
**Warning:** | ||
Using dart:mirrors can cause dart2js to generate very large JavaScript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we are ready to update this section. Maybe keep mirrors & @MirrorsUsed
but also add a paragraph about package:build
etc. Not necessarily in this PR.
cc @kevmoo to see if we're ready for this. Newcomers to Dart still learn about mirrors before anything else.
Thanks for the feedback @filiph |
Contributes to #407 and #416, wrapping up all the rest of the library tour examples.
Continuation of #443
Staged at https://dartlang-org-staging-0.firebaseapp.com/guides/libraries/library-tour#dartio---io-for-command-line-apps