Last active
March 2, 2021 06:16
-
-
Save carzacc/035fae7a2d67003e38f0792c968feee9 to your computer and use it in GitHub Desktop.
Example Flutter responsive layout login page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(context) => | |
MaterialApp( | |
home: LoginPage() | |
); | |
} | |
class LoginPage extends StatelessWidget { | |
@override | |
Widget build(context) => | |
Scaffold( | |
body: LayoutBuilder( | |
builder: (context, constraints) { | |
return AnimatedContainer( | |
duration: Duration(milliseconds: 500), | |
color: Colors.lightGreen[200], | |
padding: constraints.maxWidth < 500 ? EdgeInsets.zero : const EdgeInsets.all(30.0), | |
child: Center( | |
child: Container( | |
padding: const EdgeInsets.symmetric( | |
vertical: 30.0, horizontal: 25.0 | |
), | |
constraints: BoxConstraints( | |
maxWidth: 500, | |
), | |
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(5.0), | |
), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceAround, | |
children: [ | |
Text("Welcome to the app, please log in"), | |
TextField( | |
decoration: InputDecoration( | |
labelText: "username" | |
) | |
), | |
TextField( | |
obscureText: true, | |
decoration: InputDecoration( | |
labelText: "password" | |
) | |
), | |
RaisedButton( | |
color: Colors.blue, | |
child: Text("Log in", style: TextStyle(color: Colors.white)), | |
onPressed: () {} | |
) | |
] | |
), | |
), | |
) | |
); | |
} | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment