Skip to content

Commit 770b314

Browse files
committed
Updated Align example
1 parent 5eaeadc commit 770b314

File tree

2 files changed

+69
-54
lines changed

2 files changed

+69
-54
lines changed

25_align/ios/Runner.xcodeproj/project.pbxproj

-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
/* Begin PBXBuildFile section */
1010
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
1211
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1312
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
1413
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -40,7 +39,6 @@
4039
/* Begin PBXFileReference section */
4140
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4241
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
43-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
4442
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4543
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
4644
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -73,7 +71,6 @@
7371
9740EEB11CF90186004384FC /* Flutter */ = {
7472
isa = PBXGroup;
7573
children = (
76-
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
7774
3B80C3931E831B6300D905FE /* App.framework */,
7875
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
7976
9740EEBA1CF902C7004384FC /* Flutter.framework */,
@@ -190,7 +187,6 @@
190187
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
191188
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
192189
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
193-
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
194190
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
195191
);
196192
runOnlyForDeploymentPostprocessing = 0;

25_align/lib/main.dart

+69-50
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,89 @@
1+
// Copyright 2019 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+
15
import 'package:flutter/material.dart';
26

37
void main() => runApp(MyApp());
48

59
class MyApp extends StatelessWidget {
6-
// This widget is the root of your application.
710
@override
811
Widget build(BuildContext context) {
912
return MaterialApp(
1013
title: 'Flutter Align Demo',
11-
home: Scaffold(body: AlignExamples()),
14+
home: Scaffold(
15+
body: AlignExamples(),
16+
),
1217
);
1318
}
1419
}
1520

1621
class AlignExamples extends StatelessWidget {
1722
@override
1823
Widget build(BuildContext context) {
19-
return Column(children: <Widget>[
20-
Flexible(
21-
flex: 1,
22-
child: Align(
23-
alignment: Alignment(0, 0),
24-
child: Text('Centered!'),
25-
),
26-
),
27-
Flexible(
28-
flex: 1,
29-
child: Stack(children: <Widget>[
30-
Align(
31-
alignment: Alignment(-1, -1),
32-
child: Text('Top Left!'),
33-
),
34-
Align(
35-
alignment: Alignment(0, 0),
36-
child: Text('Centered!'),
37-
),
38-
Align(
39-
alignment: Alignment(1, 1),
40-
child: Text('Bottom Right!'),
41-
),
42-
Align(
43-
alignment: Alignment.topCenter,
44-
child: Text('TopCenter!'),
24+
return Column(
25+
children: [
26+
Flexible(
27+
flex: 1,
28+
child: Container(
29+
color: Colors.black26,
30+
child: Align(
31+
alignment: Alignment(0, 0),
32+
child: Text('Centered!'),
33+
),
4534
),
46-
Align(
47-
alignment: Alignment.bottomCenter,
48-
child: Text('TopCenter!'),
35+
),
36+
Flexible(
37+
flex: 1,
38+
child: Stack(
39+
children: <Widget>[
40+
Positioned.fill(
41+
child: Container(
42+
color: Colors.black12,
43+
),
44+
),
45+
Align(
46+
alignment: Alignment(-1, -1),
47+
child: Text('Top Left!'),
48+
),
49+
Align(
50+
alignment: Alignment(0, 0),
51+
child: Text('Centered!'),
52+
),
53+
Align(
54+
alignment: Alignment(1, 1),
55+
child: Text('Bottom Right!'),
56+
),
57+
Align(
58+
alignment: Alignment.topCenter,
59+
child: Text('TopCenter!'),
60+
),
61+
Align(
62+
alignment: Alignment.bottomCenter,
63+
child: Text('TopCenter!'),
64+
),
65+
],
4966
),
50-
]),
51-
),
52-
Flexible(
53-
flex: 1,
54-
child: Container(
55-
child: Align(
56-
alignment: Alignment(-.5, -.5),
57-
child: Text('25% in'),
58-
)),
59-
),
60-
Flexible(
61-
flex: 1,
62-
child: Container(
63-
child: Align(
64-
alignment: Alignment(.5, .5),
65-
child: Text('75% in'),
66-
)),
67-
),
68-
]);
67+
),
68+
Flexible(
69+
flex: 1,
70+
child: Container(
71+
color: Colors.black26,
72+
child: Align(
73+
alignment: Alignment(-.5, -.5),
74+
child: Text('25% in'),
75+
)),
76+
),
77+
Flexible(
78+
flex: 1,
79+
child: Container(
80+
color: Colors.black12,
81+
child: Align(
82+
alignment: Alignment(.5, .5),
83+
child: Text('75% in'),
84+
)),
85+
),
86+
],
87+
);
6988
}
7089
}

0 commit comments

Comments
 (0)