Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 61 additions & 62 deletions src/docs/development/packages-and-plugins/using-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,32 @@ To use this package:

1. Open `lib/main.dart` and replace its full contents with:

```dart
import 'package:css_colors/css_colors.dart';
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DemoPage(),
);
}
}

class DemoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(body: Container(color: CSSColors.orange));
}
}
```

1. Run the app. When you click the 'Show Flutter homepage' you should see the
phone's default browser open, and the Flutter homepage appear.
```dart
import 'package:css_colors/css_colors.dart';
import 'package:flutter/material.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DemoPage(),
);
}
}

class DemoPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(body: Container(color: CSSColors.orange));
}
}
```

1. Run the app. You can see app's background color is orange.


### Example: Using the URL Launcher package to launch the browser {#url-example}
Expand Down Expand Up @@ -257,41 +256,41 @@ To use this plugin:

1. Open `lib/main.dart` and replace its full contents with:

```dart
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DemoPage(),
);
}
}

class DemoPage extends StatelessWidget {
launchURL() {
launch('https://flutter.io');
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(
onPressed: launchURL,
child: Text('Show Flutter homepage'),
),
),
);
}
}
```
```dart
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DemoPage(),
);
}
}

class DemoPage extends StatelessWidget {
launchURL() {
launch('https://flutter.io');
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(
onPressed: launchURL,
child: Text('Show Flutter homepage'),
),
),
);
}
}
```

1. Run the app (or stop and restart it, if you already had it running
before adding the plugin). When you click the 'Show Flutter homepage'
Expand Down