Created
January 10, 2021 19:37
-
-
Save dolpheen/95e6f965eaf29dfc40967a3a2151a388 to your computer and use it in GitHub Desktop.
Futter hack sample demo
This file contains 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 { | |
static const String _title = 'Super App'; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: _title, | |
home: Scaffold( | |
appBar: AppBar( | |
title: const Text(_title), | |
backgroundColor: Colors.blue, | |
), | |
body: const MyStatefulWidget(), | |
), | |
); | |
} | |
} | |
class MyStatefulWidget extends StatefulWidget { | |
const MyStatefulWidget({Key key}) : super(key: key); | |
@override | |
_MyStatefulWidgetState createState() => _MyStatefulWidgetState(); | |
} | |
// Our secret password | |
const _secret = 'secret'; | |
class _MyStatefulWidgetState extends State<MyStatefulWidget> { | |
final _formKey = GlobalKey<FormState>(); | |
@override | |
Widget build(BuildContext context) { | |
return Form( | |
key: _formKey, | |
child: Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 10), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
TextFormField( | |
decoration: const InputDecoration( | |
hintText: 'Enter your password', | |
), | |
validator: (value) { | |
if (value != _secret) { | |
return 'Wrong password'; | |
} | |
return null; | |
}, | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(vertical: 16.0), | |
child: ElevatedButton( | |
onPressed: () { | |
if (_formKey.currentState.validate()) { | |
showDialog( | |
context: context, | |
builder: (context) => Center( | |
child: Card( | |
color: Colors.white, | |
child: Container( | |
padding: const EdgeInsets.fromLTRB(80, 20, 80, 20), | |
child: const Text( | |
'You are in !!!', | |
style: TextStyle(fontSize: 30), | |
), | |
), | |
), | |
), | |
); | |
} | |
}, | |
child: const Text('Submit'), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment