Skip to content

Instantly share code, notes, and snippets.

@afzalali15
Last active May 31, 2020 17:40
Show Gist options
  • Save afzalali15/85d786f8639274a28676e0e84970e066 to your computer and use it in GitHub Desktop.
Save afzalali15/85d786f8639274a28676e0e84970e066 to your computer and use it in GitHub Desktop.
DartPad demo with Flutter application
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'DartPad Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.purple, Colors.blue],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FlutterLogo(size: 144),
ConstrainedBox(
constraints: BoxConstraints(maxWidth: 400),
child: Card(
elevation: 8.0,
margin: const EdgeInsets.all(32.0),
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
'Login',
style: TextStyle(fontSize: 48),
),
SizedBox(height: 32),
TextField(
decoration: InputDecoration(hintText: 'Username'),
),
TextField(
decoration: InputDecoration(hintText: 'Password'),
obscureText: true,
),
SizedBox(height: 32),
FloatingActionButton.extended(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => DetailPage(),
));
},
label: Text('Login'),
icon: Icon(Icons.send),
),
],
),
),
),
),
IconButton(
icon: Icon(Icons.info),
color: Colors.white54,
onPressed: () {
showAboutDialog(context: context, applicationVersion: 'v 1.0');
},
),
],
),
),
);
}
}
class DetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment