Skip to content

Layout widgets: Container example app #2307

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

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions examples/layout/container/README.md
56 changes: 56 additions & 0 deletions examples/layout/container/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;

void main() {
debugPaintSizeEnabled = false; // Set to true for visual layout
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter layout demo',
home: Scaffold(
appBar: AppBar(
title: Text('Flutter layout demo'),
),
body: Center(child: _buildImageColumn()),
),
);
}

// #docregion column
Widget _buildImageColumn() => Container(
decoration: BoxDecoration(
color: Colors.black26,
),
child: Column(
children: [
_buildImageRow(1),
_buildImageRow(3),
],
),
);
// #enddocregion column

// #docregion row
Widget _buildDecoratedImage(int imageIndex) => Expanded(
child: Container(
decoration: BoxDecoration(
border: Border.all(width: 10, color: Colors.black38),
borderRadius: const BorderRadius.all(const Radius.circular(8)),
),
margin: const EdgeInsets.all(4),
child: Image.asset('images/pic$imageIndex.jpg'),
),
);

Widget _buildImageRow(int imageIndex) => Row(
children: [
_buildDecoratedImage(imageIndex),
_buildDecoratedImage(imageIndex + 1),
],
);
// #enddocregion row
}
24 changes: 24 additions & 0 deletions examples/layout/container/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: layout
description: >
Sample app from "Building Layouts", https://flutter.io/docs/development/ui/layout.
version: 1.0.0

environment:
sdk: '>=2.0.0-dev.68.0 <3.0.0'

dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2

dev_dependencies:
flutter_test:
sdk: flutter

flutter:
uses-material-design: true
assets:
- images/pic1.jpg
- images/pic2.jpg
- images/pic3.jpg
- images/pic4.jpg
14 changes: 14 additions & 0 deletions examples/layout/container/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Basic Flutter widget test. Learn more at https://flutter.io/docs/testing.

import 'package:flutter_test/flutter_test.dart';
import 'package:layout/main.dart';

void main() {
testWidgets('Example app smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

expect(find.text('Flutter layout demo'), findsOneWidget);
// TODO: test more app features.
});
}
2 changes: 1 addition & 1 deletion examples/layout/pavlova/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled;

void main() {
debugPaintSizeEnabled = false; // Remove to suppress visual layout
debugPaintSizeEnabled = false; // Set to true for visual layout
runApp(MyApp());
}

Expand Down
9 changes: 0 additions & 9 deletions src/_includes/code/layout/container/.gitignore

This file was deleted.

110 changes: 0 additions & 110 deletions src/_includes/code/layout/container/main.dart

This file was deleted.

14 changes: 0 additions & 14 deletions src/_includes/code/layout/container/pubspec.yaml

This file was deleted.

Loading