Skip to content

Commit 1f4c7f5

Browse files
author
Gordon Hayes
committed
fix: overflow
1 parent 7956b94 commit 1f4c7f5

File tree

3 files changed

+61
-20
lines changed

3 files changed

+61
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:flutter/material.dart';
2+
3+
class DetermineVisibility extends StatelessWidget {
4+
const DetermineVisibility({
5+
Key? key,
6+
required this.child,
7+
}) : super(key: key);
8+
9+
final Widget child;
10+
@override
11+
Widget build(BuildContext context) {
12+
return LayoutBuilder(
13+
builder: (context, constraints) {
14+
return Visibility(
15+
visible: constraints.maxWidth > 200 && constraints.maxHeight > 50,
16+
child: child,
17+
);
18+
},
19+
);
20+
}
21+
}

section_4/login_example_sequence_animation/lib/widgets/forms/login_form.dart

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:login/widgets/determine_visibility.dart';
23

34
import '../../styles/colors.dart';
45
import 'call_to_action_button.dart';
@@ -43,16 +44,25 @@ class LoginForm extends StatelessWidget {
4344
text: 'Login',
4445
color: headerLoginColor,
4546
),
46-
Row(
47-
mainAxisAlignment: MainAxisAlignment.center,
48-
children: <Widget>[
49-
const CallToActionText("Don't have an account?"),
50-
CallToActionButton(
51-
onPressed: onSignUpPressed,
52-
text: 'Sign Up',
53-
color: headerSignUpColor,
54-
),
55-
],
47+
DetermineVisibility(
48+
child: Row(
49+
mainAxisAlignment: MainAxisAlignment.center,
50+
children: <Widget>[
51+
const Expanded(
52+
flex: 3,
53+
child: Center(
54+
child: CallToActionText("Don't have an account?")),
55+
),
56+
Expanded(
57+
flex: 1,
58+
child: CallToActionButton(
59+
onPressed: onSignUpPressed,
60+
text: 'Sign Up',
61+
color: headerSignUpColor,
62+
),
63+
),
64+
],
65+
),
5666
),
5767
],
5868
),

section_4/login_example_sequence_animation/lib/widgets/forms/signup_form.dart

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../../styles/colors.dart';
4+
import '../determine_visibility.dart';
45
import 'call_to_action_button.dart';
56
import 'call_to_action_text.dart';
67
import 'text_input_box.dart';
@@ -47,16 +48,25 @@ class SignUpForm extends StatelessWidget {
4748
onPressed: onSignUpPressed,
4849
text: 'Sign Up',
4950
color: headerSignUpColor),
50-
Row(
51-
mainAxisAlignment: MainAxisAlignment.center,
52-
children: <Widget>[
53-
const CallToActionText('Already have an account?'),
54-
CallToActionButton(
55-
text: 'Sign in',
56-
onPressed: onLoginPressed,
57-
color: headerLoginColor,
58-
)
59-
],
51+
DetermineVisibility(
52+
child: Row(
53+
mainAxisAlignment: MainAxisAlignment.center,
54+
children: <Widget>[
55+
const Expanded(
56+
flex: 3,
57+
child: Center(
58+
child: CallToActionText('Already have an account?')),
59+
),
60+
Expanded(
61+
flex: 1,
62+
child: CallToActionButton(
63+
text: 'Sign in',
64+
onPressed: onLoginPressed,
65+
color: headerLoginColor,
66+
),
67+
)
68+
],
69+
),
6070
),
6171
],
6272
),

0 commit comments

Comments
 (0)