Skip to content

Commit 75dc0b2

Browse files
committed
Rework of "Lay out a widget" + use of code-excerpts
Contributes to #2233
1 parent ecbc9aa commit 75dc0b2

File tree

10 files changed

+184
-168
lines changed

10 files changed

+184
-168
lines changed

examples/layout/base/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../README.md
1+
../../README.md

examples/layout/base/lib/main.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22

33
void main() => runApp(MyApp());
44

5+
// #docregion MyApp
56
class MyApp extends StatelessWidget {
67
@override
78
Widget build(BuildContext context) {
@@ -11,9 +12,13 @@ class MyApp extends StatelessWidget {
1112
appBar: AppBar(
1213
title: Text('Flutter layout demo'),
1314
),
15+
// #docregion centered-text
1416
body: Center(
17+
// #docregion text
1518
child: Text('Hello World'),
19+
// #enddocregion text
1620
),
21+
// #enddocregion centered-text
1722
),
1823
);
1924
}

examples/layout/lakes/step5/lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ class MyApp extends StatelessWidget {
3434
),
3535
),
3636
/*3*/
37+
// #docregion Icon
3738
Icon(
3839
Icons.star,
3940
color: Colors.red[500],
4041
),
42+
// #enddocregion Icon
4143
Text('41'),
4244
],
4345
),
@@ -79,12 +81,14 @@ class MyApp extends StatelessWidget {
7981
),
8082
body: Column(
8183
children: [
84+
// #docregion Image-asset
8285
Image.asset(
8386
'images/lake.jpg',
8487
width: 600.0,
8588
height: 240.0,
8689
fit: BoxFit.cover,
8790
),
91+
// #enddocregion Image-asset
8892
titleSection,
8993
buttonSection,
9094
textSection,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

src/_includes/code/layout/widgets-only/main.dart renamed to examples/layout/non_material/lib/main.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
// Copyright 2017 The Chromium Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
4-
5-
// This app doesn't use any material widgets, such as Scaffold.
1+
// This app doesn't use any Material widgets, such as Scaffold.
62
// Normally, an app that doesn't use Scaffold has a black background
73
// and the default text color is black. This app changes its background
84
// to white and its text color to dark grey to mimic a material app.
5+
96
import 'package:flutter/material.dart';
107

11-
void main() {
12-
runApp(MyApp());
13-
}
8+
void main() => runApp(MyApp());
149

10+
// #docregion MyApp
1511
class MyApp extends StatelessWidget {
1612
@override
1713
Widget build(BuildContext context) {
1814
return Container(
1915
decoration: BoxDecoration(color: Colors.white),
2016
child: Center(
21-
child: Text('Hello World',
22-
textDirection: TextDirection.ltr,
23-
style: TextStyle(fontSize: 40.0, color: Colors.black87)),
17+
child: Text(
18+
'Hello World',
19+
textDirection: TextDirection.ltr,
20+
style: TextStyle(
21+
fontSize: 32.0,
22+
color: Colors.black87,
23+
),
24+
),
2425
),
2526
);
2627
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: layout
2+
description: >
3+
Sample app from "Building Layouts", https://flutter.io/docs/development/ui/layout.
4+
version: 1.0.0
5+
6+
environment:
7+
sdk: '>=2.0.0-dev.68.0 <3.0.0'
8+
9+
dependencies:
10+
flutter:
11+
sdk: flutter
12+
cupertino_icons: ^0.1.2
13+
14+
dev_dependencies:
15+
flutter_test:
16+
sdk: flutter
17+
18+
flutter:
19+
uses-material-design: true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Basic Flutter widget test. Learn more at https://flutter.io/docs/testing.
2+
3+
import 'package:flutter_test/flutter_test.dart';
4+
5+
import 'package:layout/main.dart';
6+
7+
void main() {
8+
testWidgets('Codelab smoke test', (WidgetTester tester) async {
9+
await tester.pumpWidget(new MyApp());
10+
expect(find.text('Hello World'), findsOneWidget);
11+
});
12+
}

src/_includes/code/layout/widgets-only/.gitignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/_includes/code/layout/widgets-only/pubspec.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)