-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathflutter_hooks.dart
56 lines (53 loc) · 1.81 KB
/
flutter_hooks.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
class MyFlutterHooks extends HookWidget {
const MyFlutterHooks({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final usernameController = useTextEditingController();
final passwordController = useTextEditingController();
return Scaffold(
appBar: AppBar(title: const Text('Flutter Hooks')),
body: Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Enter Name Here',
hintText: 'Enter Name Here',
),
controller: usernameController,
),
const SizedBox(height: 30),
TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Enter Password Here',
hintText: 'Enter Password Here',
),
controller: passwordController,
),
const SizedBox(height: 30),
ElevatedButton(
child: const Text('Login'),
onPressed: () {
final usr = usernameController.text;
final pwd = passwordController.text;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Logged in with $usr and $pwd'),
),
);
},
),
],
),
),
),
);
}
}