This repository was archived by the owner on Dec 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathflows_content.dart
More file actions
158 lines (150 loc) · 4.93 KB
/
flows_content.dart
File metadata and controls
158 lines (150 loc) · 4.93 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
part of '../../main.dart';
class FlowsContent extends StatefulWidget {
const FlowsContent({Key? key}) : super(key: key);
@override
State<FlowsContent> createState() => _FlowsContentState();
}
class _FlowsContentState extends State<FlowsContent> {
final flowNameController = TextEditingController();
final flowKeyAttributeController = TextEditingController();
final flowValueAttributeController = TextEditingController();
bool? didFlowEnd;
@override
Widget build(BuildContext context) {
final textTheme = Theme.of(context).textTheme;
return Column(
children: [
InstabugTextField(
label: 'Flow name',
symanticLabel: 'flow_name_input',
labelStyle: textTheme.labelMedium,
controller: flowNameController,
),
SizedBox.fromSize(
size: const Size.fromHeight(10.0),
),
Row(
children: [
Flexible(
flex: 5,
child: InstabugButton.smallFontSize(
text: 'Start Flow',
symanticLabel: 'start_flow',
onPressed: () => _startFlow(flowNameController.text),
margin: const EdgeInsetsDirectional.only(
start: 20.0,
end: 10.0,
),
),
),
Flexible(
flex: 5,
child: InstabugButton.smallFontSize(
text: 'Start flow With Delay',
symanticLabel: 'start_flow_with_delay',
onPressed: () => _startFlow(
flowNameController.text,
delayInMilliseconds: 5000,
),
margin: const EdgeInsetsDirectional.only(
start: 10.0,
end: 20.0,
),
),
),
],
),
Row(
children: [
Flexible(
flex: 5,
child: InstabugTextField(
label: 'Flow Key Attribute',
symanticLabel: 'flow_key_input',
controller: flowKeyAttributeController,
labelStyle: textTheme.labelMedium,
margin: const EdgeInsetsDirectional.only(
end: 10.0,
start: 20.0,
),
),
),
Flexible(
flex: 5,
child: InstabugTextField(
label: 'Flow Value Attribute',
symanticLabel: 'flow_value_input',
labelStyle: textTheme.labelMedium,
controller: flowValueAttributeController,
margin: const EdgeInsetsDirectional.only(
start: 10.0,
end: 20.0,
),
),
),
],
),
SizedBox.fromSize(
size: const Size.fromHeight(10.0),
),
InstabugButton(
text: 'Set Flow Attribute',
symanticLabel: 'set_flow_attribute',
onPressed: () => _setFlowAttribute(
flowNameController.text,
flowKeyAttribute: flowKeyAttributeController.text,
flowValueAttribute: flowValueAttributeController.text,
),
),
InstabugButton(
text: 'End Flow',
symanticLabel: 'end_flow',
onPressed: () => _endFlow(flowNameController.text),
),
],
);
}
void _startFlow(
String flowName, {
int delayInMilliseconds = 0,
}) {
if (flowName.trim().isNotEmpty) {
log('_startFlow — flowName: $flowName, delay in Milliseconds: $delayInMilliseconds');
log('flowName: $flowName');
Future.delayed(Duration(milliseconds: delayInMilliseconds),
() => APM.startFlow(flowName));
} else {
log('_startFlow - Please enter a flow name');
}
}
void _endFlow(String flowName) {
if (flowName.trim().isEmpty) {
log('_endFlow - Please enter a flow name');
}
if (didFlowEnd == true) {
log('_endFlow — Please, start a new flow before setting attributes.');
}
log('_endFlow — ending Flow.');
didFlowEnd = true;
}
void _setFlowAttribute(
String flowName, {
required String flowKeyAttribute,
required String flowValueAttribute,
}) {
if (flowName.trim().isEmpty) {
log('_endFlow - Please enter a flow name');
}
if (didFlowEnd == true) {
log('_setFlowAttribute — Please, start a new flow before setting attributes.');
}
if (flowKeyAttribute.trim().isEmpty) {
log('_setFlowAttribute — Please, fill the flow key attribute input before settings attributes.');
}
if (flowValueAttribute.trim().isEmpty) {
log('_setFlowAttribute — Please, fill the flow value attribute input before settings attributes.');
}
log('_setFlowAttribute — setting attributes -> key: $flowKeyAttribute, value: $flowValueAttribute.');
APM.setFlowAttribute(flowName, flowKeyAttribute, flowValueAttribute);
}
}