Skip to content

Commit

Permalink
Fixed Scaffold.of() context issue
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
albertms10 committed May 18, 2020
1 parent e06319a commit 3da8e92
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
113 changes: 54 additions & 59 deletions lib/login_flow/pages/signin_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,70 +54,65 @@ class _SignInPageState extends State<SignInPage> {

@override
Widget build(BuildContext context) {
if (_showProgress) {
return Scaffold(
body: Center(child: CircularProgressIndicator()),
);
}
if (_showProgress) return Center(child: CircularProgressIndicator());

final SignInConfig config = Provider.of<SignInConfig>(context);
final primaryColor = Theme.of(context).primaryColor;
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
child: Form(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(height: 120),
AuthPageTitle('Sign In'),
SizedBox(height: 24),
SignInTextField(SignInTextFieldType.email, _email),
SizedBox(height: 16),
SignInTextField(SignInTextFieldType.password, _password),
SizedBox(height: 32),
SignInButton(
color: primaryColor,
onPressed: () =>
_waitAndCheckErrors(_signInWithEmailAndPassword),
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Need an account?',
style: TextStyle(
color: Colors.black45,
fontStyle: FontStyle.italic,
),
),
SizedBox(width: 16),
FlatButton(
child: Text('Register'),
textColor: primaryColor,
onPressed: () async {
EmailAndPassword result =
await Navigator.of(context).push(
MaterialPageRoute(builder: (_) => SignUpPage()),
);
_createUserWithEmailAndPassword(result);
},

return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0),
child: Form(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(height: 120),
AuthPageTitle('Sign In'),
SizedBox(height: 24),
SignInTextField(SignInTextFieldType.email, _email),
SizedBox(height: 16),
SignInTextField(SignInTextFieldType.password, _password),
SizedBox(height: 32),
SignInButton(
color: primaryColor,
onPressed: () =>
_waitAndCheckErrors(_signInWithEmailAndPassword),
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Need an account?',
style: TextStyle(
color: Colors.black45,
fontStyle: FontStyle.italic,
),
],
),
SizedBox(height: 40),
if (config.canLoginAnonymously)
),
SizedBox(width: 16),
FlatButton(
child: Text(
'Sign in anonymously',
style: TextStyle(color: Colors.grey[500]),
),
onPressed: () => _waitAndCheckErrors(_signInAnonymously),
child: Text('Register'),
textColor: primaryColor,
onPressed: () async {
EmailAndPassword result =
await Navigator.of(context).push(
MaterialPageRoute(builder: (_) => SignUpPage()),
);
_createUserWithEmailAndPassword(result);
},
),
],
),
],
),
SizedBox(height: 40),
if (config.canLoginAnonymously)
FlatButton(
child: Text(
'Sign in anonymously',
style: TextStyle(color: Colors.grey[500]),
),
onPressed: () => _waitAndCheckErrors(_signInAnonymously),
),
],
),
),
),
Expand Down
7 changes: 6 additions & 1 deletion lib/login_flow/signin_flow_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import 'package:stay_home_polls_app/login_flow/pages/signin_page.dart';
class SignInFlowApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(home: SignInPage());
return MaterialApp(
home: Scaffold(
body: SignInPage(),
backgroundColor: Colors.white,
),
);
}
}

0 comments on commit 3da8e92

Please sign in to comment.