Skip to content

Instantly share code, notes, and snippets.

@thanhhaiqtvn
Last active June 14, 2021 09:46
Show Gist options
  • Save thanhhaiqtvn/f02aeb2769b4546e19ded837b59004de to your computer and use it in GitHub Desktop.
Save thanhhaiqtvn/f02aeb2769b4546e19ded837b59004de to your computer and use it in GitHub Desktop.
Sharing dart code
import 'package:flutter/material.dart';
class MainScreen extends StatefulWidget {
const MainScreen();
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: LayoutBuilder(
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: IntrinsicHeight(
child: Padding(
padding: EdgeInsets.all(15),
child: Column(
children: <Widget>[
Expanded(
child: Center(
child: Container(
color: const Color(0xffeeee00),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const TextField(
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Username',
),
),
const TextField(
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Password',
),
),
TextButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all<Color>(
Colors.blue),
),
onPressed: () {},
child: const Text('Login'),
),
],
),
),
),
),
Container(
color: const Color(0xff008000),
alignment: Alignment.center,
child: Column(
children: [
TextButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all<Color>(
Colors.white),
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.blue),
),
onPressed: () {},
child: const Text('Bottom Button 1'),
),
TextButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all<Color>(
Colors.white),
backgroundColor:
MaterialStateProperty.all<Color>(
Colors.blue),
),
onPressed: () {},
child: const Text('Bottom Button 2'),
)
],
),
),
],
),
),
),
),
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment