@@ -3,9 +3,17 @@ import 'package:flutter_constraintlayout/src/constraint_layout.dart';
33
44import 'custom_app_bar.dart' ;
55
6- class WrapperConstraintsExample extends StatelessWidget {
6+ class WrapperConstraintsExample extends StatefulWidget {
77 const WrapperConstraintsExample ({Key ? key}) : super (key: key);
88
9+ @override
10+ State createState () => WrapperConstraintsExampleState ();
11+ }
12+
13+ class WrapperConstraintsExampleState extends State <WrapperConstraintsExample > {
14+ double leftX = 0 ;
15+ double rightX = 0 ;
16+
917 Widget item (String text, [Color color = Colors .redAccent]) {
1018 return Container (
1119 width: 100 ,
@@ -55,6 +63,9 @@ class WrapperConstraintsExample extends StatelessWidget {
5563 ),
5664 item ('centerTopRightTo' ).applyConstraint (
5765 centerTopRightTo: rId (0 ),
66+ callback: (_, rect) {
67+ leftX = rect.right;
68+ },
5869 ),
5970 item ('centerCenterLeftTo' ).applyConstraint (
6071 centerCenterLeftTo: rId (0 ),
@@ -83,6 +94,12 @@ class WrapperConstraintsExample extends StatelessWidget {
8394 ),
8495 item ('outTopLeftTo' ).applyConstraint (
8596 outTopLeftTo: rId (1 ),
97+ callback: (_, rect) {
98+ rightX = rect.left;
99+ WidgetsBinding .instance! .addPostFrameCallback ((timeStamp) {
100+ setState (() {});
101+ });
102+ },
86103 ),
87104 item ('outTopCenterTo' ).applyConstraint (
88105 outTopCenterTo: rId (1 ),
@@ -132,6 +149,20 @@ class WrapperConstraintsExample extends StatelessWidget {
132149 item ('bottomRightTo' , Colors .green).applyConstraint (
133150 bottomRightTo: rId (1 ),
134151 ),
152+ const Text (
153+ 'The display area is overlapping\n Please view it in full screen on the computer' ,
154+ style: TextStyle (
155+ color: Colors .redAccent,
156+ fontSize: 16 ,
157+ ),
158+ textAlign: TextAlign .center,
159+ ).applyConstraint (
160+ topCenterTo: parent,
161+ margin: const EdgeInsets .only (
162+ top: 5 ,
163+ ),
164+ visibility: rightX - 1 < leftX ? visible : gone,
165+ ),
135166 ],
136167 ),
137168 );
0 commit comments