Skip to content

Commit b840358

Browse files
committed
[feat] press enter to send request
Triggers `sendRequest` when enter is clicked and `URLField` is in focus.
1 parent 6a886df commit b840358

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/screens/home_page/editor_pane/url_card.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ class URLTextField extends ConsumerWidget {
8181
.read(collectionStateNotifierProvider.notifier)
8282
.update(selectedId, url: value);
8383
},
84+
onFieldSubmitted: (value) {
85+
ref
86+
.read(collectionStateNotifierProvider.notifier)
87+
.sendRequest(selectedId);
88+
},
8489
);
8590
}
8691
}

lib/widgets/textfields.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ class URLField extends StatelessWidget {
77
required this.selectedId,
88
this.initialValue,
99
this.onChanged,
10+
this.onFieldSubmitted,
1011
});
1112

1213
final String selectedId;
1314
final String? initialValue;
1415
final void Function(String)? onChanged;
16+
final void Function(String)? onFieldSubmitted;
1517

1618
@override
1719
Widget build(BuildContext context) {
@@ -29,6 +31,7 @@ class URLField extends StatelessWidget {
2931
border: InputBorder.none,
3032
),
3133
onChanged: onChanged,
34+
onFieldSubmitted: onFieldSubmitted,
3235
);
3336
}
3437
}

0 commit comments

Comments
 (0)