-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy path06. auto_email_attacher.dart
80 lines (73 loc) · 2.64 KB
/
06. auto_email_attacher.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import 'package:awesome_widgets/awesome_widgets.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class LoginNotifier extends ChangeNotifier {
final TextEditingController emailController = TextEditingController();
String attachedProvider = "";
attachEmailProvider({required String provider}) {
emailController.text = emailController.text + provider;
attachedProvider = provider;
notifyListeners();
}
clearTextFieldState() {
emailController.clear();
attachedProvider = "";
notifyListeners();
}
}
class DemoLoginView extends StatelessWidget {
const DemoLoginView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
LoginNotifier loginNotifier({required bool renderUI}) =>
Provider.of<LoginNotifier>(context, listen: renderUI);
return Scaffold(
body: Container(
child: Column(
children: [
AwesomeTextfield.filled(
textEditingController:
loginNotifier(renderUI: false).emailController,
fillColor: Colors.grey),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ActionChipButton(
backgroundColor:
loginNotifier(renderUI: true).attachedProvider ==
"@yahoo.com"
? Colors.blue
: Colors.greenAccent,
onTap: () {
loginNotifier(renderUI: false)
.attachEmailProvider(provider: "@yahoo.com");
},
label: "@yahoo.com"),
ActionChipButton(
backgroundColor:
loginNotifier(renderUI: true).attachedProvider ==
"@hotmail.com"
? Colors.blue
: Colors.greenAccent,
onTap: () {
loginNotifier(renderUI: false)
.attachEmailProvider(provider: "@hotmail.com");
},
label: "@hotmail.com"),
],
),
if (loginNotifier(renderUI: true).attachedProvider != "")
Align(
alignment: Alignment.centerRight,
child: ActionChip(
onPressed: () {
loginNotifier(renderUI: false).clearTextFieldState();
},
label: const Text("clear")),
),
],
),
),
);
}
}