Commit b5347ce5 authored by Adam Barth's avatar Adam Barth

Improve the READMEs further

parent 1b440cc6
Getting Started with Sky Getting started with Sky
======================== ========================
Sky apps are written in Dart. To get started, we need to set up Dart SDK: Sky apps are written in Dart. To get started, we need to set up Dart SDK:
- Install the [Dart SDK](https://www.dartlang.org/downloads/). - Install the [Dart SDK](https://www.dartlang.org/downloads/).
- Ensure that `$DART_SDK` is set to the path of your Dart SDK. - Ensure that `$DART_SDK` is set to the path of your Dart SDK and that the
`dart` and `pub` executables are on your `$PATH`.
Once we have the Dart SDK, we can creating a new directory and Once we have the Dart SDK, we can creating a new directory and
adding a [pubspec.yaml](https://www.dartlang.org/tools/pub/pubspec.html): adding a [pubspec.yaml](https://www.dartlang.org/tools/pub/pubspec.html):
...@@ -15,24 +16,22 @@ dependencies: ...@@ -15,24 +16,22 @@ dependencies:
sky: any sky: any
``` ```
Once the pubspec is in place, create a `lib` directory (where your dart code Once the `pubspec.yaml` is in place, create a `lib` directory (where your Dart\
will go) ensure that the 'dart' and 'pub' executables are on your $PATH and code will go) and use the `pub` tool to fetch the Sky package and its
run the following: dependencies:
- `mkdir lib` - `mkdir lib`
- `pub get && pub run sky:init` - `pub get && pub run sky:init`
Currently the Sky Engine assumes the entry point for your application is a Currently Sky assumes the entry point for your application is a `main` function
`main` function in `lib/main.dart`: in `lib/main.dart`:
```dart ```dart
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
class HelloWorldApp extends App { class HelloWorldApp extends App {
Widget build() { Widget build() {
return new Center( return new Center(child: new Text('Hello, world!'));
child: new Text('Hello, world!')
);
} }
} }
...@@ -41,11 +40,9 @@ void main() { ...@@ -41,11 +40,9 @@ void main() {
} }
``` ```
Execution starts in `main`, which instructs the framework to run a new Execution starts in `main`, which runs a new instance of the `HelloWorldApp`.
instance of the `HelloWorldApp`. The framework then calls the `build()` The `HelloWorldApp` builds a `Text` widget containing the famous _Hello, world!_
function on `HelloWorldApp` to create a tree of widgets, some of which might string and centers it on the screen using a `Center` widget. To learn more about
be other `Components`, which in turn have `build()` functions that generate
more widgets iteratively to create the widget hierarchy. To learn more about
the widget system, please see the [widgets tutorial](lib/widgets/README.md). the widget system, please see the [widgets tutorial](lib/widgets/README.md).
Setup your Android device Setup your Android device
...@@ -84,15 +81,6 @@ follow these instructions: ...@@ -84,15 +81,6 @@ follow these instructions:
`adb logcat -s sky` can be used to filter only adb messages from `adb logcat -s sky` can be used to filter only adb messages from
`SkyDemo.apk`. `SkyDemo.apk`.
Building a standalone APK
-------------------------
Although it is possible to build a standalone APK containing your application,
doing so right now is difficult. If you're feeling brave, you can see how we
build the `Stocks.apk` in [example/stocks](example/stocks). Eventually we plan
to make this much easier and support platforms other than Android, but that work
still in progress.
Debugging Debugging
--------- ---------
...@@ -100,3 +88,12 @@ Sky uses [Observatory](https://www.dartlang.org/tools/observatory/) for ...@@ -100,3 +88,12 @@ Sky uses [Observatory](https://www.dartlang.org/tools/observatory/) for
debugging and profiling. While running your Sky app using `sky_tool`, you can debugging and profiling. While running your Sky app using `sky_tool`, you can
access Observatory by navigating your web browser to access Observatory by navigating your web browser to
[http://localhost:8181/](http://localhost:8181/). [http://localhost:8181/](http://localhost:8181/).
Building a standalone APK
-------------------------
Although it is possible to build a standalone APK containing your application,
doing so right now is difficult. If you're feeling brave, you can see how we
build the `Stocks.apk` in [example/stocks](example/stocks). Eventually we plan
to make this much easier and support platforms other than Android, but that work
still in progress.
...@@ -12,14 +12,14 @@ in the underlying render tree to transition from one state to the next. ...@@ -12,14 +12,14 @@ in the underlying render tree to transition from one state to the next.
Hello World Hello World
----------- -----------
To build an application, create a subclass of App and instantiate it: To build an application, create a subclass of `App` and instantiate it:
```dart ```dart
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
class HelloWorldApp extends App { class HelloWorldApp extends App {
Widget build() { Widget build() {
return new Text('Hello, world!'); return new Center(child: new Text('Hello, world!'));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment