Skip to content

Commit 794f3cf

Browse files
authored
Merge pull request #198 from Tanish2002/update_flutter_typehead
feat: update flutter_typeahead
2 parents 3224250 + b802ca7 commit 794f3cf

File tree

3 files changed

+89
-38
lines changed

3 files changed

+89
-38
lines changed

lib/widgets/headerfield.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import 'package:apidash/consts.dart';
12
import 'package:apidash/utils/header_utils.dart';
23
import 'package:flutter/material.dart';
3-
import 'package:apidash/consts.dart';
44
import 'package:flutter_typeahead/flutter_typeahead.dart';
55

66
class HeaderField extends StatefulWidget {
@@ -41,6 +41,7 @@ class _HeaderFieldState extends State<HeaderField> {
4141

4242
@override
4343
void didUpdateWidget(HeaderField oldWidget) {
44+
super.didUpdateWidget(oldWidget);
4445
if (oldWidget.initialValue != widget.initialValue) {
4546
controller.text = widget.initialValue ?? "";
4647
controller.selection =
@@ -54,8 +55,8 @@ class _HeaderFieldState extends State<HeaderField> {
5455
return TypeAheadField(
5556
key: Key(widget.keyId),
5657
hideOnEmpty: true,
57-
minCharsForSuggestions: 1,
58-
onSuggestionSelected: (value) {
58+
controller: controller,
59+
onSelected: (value) {
5960
setState(() {
6061
controller.text = value;
6162
});
@@ -68,19 +69,17 @@ class _HeaderFieldState extends State<HeaderField> {
6869
);
6970
},
7071
suggestionsCallback: headerSuggestionCallback,
71-
suggestionsBoxDecoration: suggestionBoxDecorations(context),
72-
textFieldConfiguration: TextFieldConfiguration(
72+
decorationBuilder: (context, child) =>
73+
suggestionBoxDecorations(context, child, colorScheme),
74+
constraints: const BoxConstraints(maxHeight: 400),
75+
builder: (context, controller, focusNode) => TextField(
7376
onChanged: widget.onChanged,
7477
controller: controller,
75-
style: kCodeStyle.copyWith(
76-
color: colorScheme.onSurface,
77-
),
78+
focusNode: focusNode,
79+
style: kCodeStyle.copyWith(color: colorScheme.onSurface),
7880
decoration: InputDecoration(
7981
hintStyle: kCodeStyle.copyWith(
80-
color: colorScheme.outline.withOpacity(
81-
kHintOpacity,
82-
),
83-
),
82+
color: colorScheme.outline.withOpacity(kHintOpacity)),
8483
hintText: widget.hintText,
8584
focusedBorder: UnderlineInputBorder(
8685
borderSide: BorderSide(
@@ -99,22 +98,26 @@ class _HeaderFieldState extends State<HeaderField> {
9998
);
10099
}
101100

102-
SuggestionsBoxDecoration suggestionBoxDecorations(BuildContext context) {
103-
return SuggestionsBoxDecoration(
104-
elevation: 4,
105-
constraints: const BoxConstraints(maxHeight: 400),
106-
shape: RoundedRectangleBorder(
107-
side: BorderSide(
108-
color: Theme.of(context).dividerColor,
109-
width: 1.2,
101+
Theme suggestionBoxDecorations(
102+
BuildContext context, Widget child, ColorScheme colorScheme) {
103+
return Theme(
104+
data: ThemeData(colorScheme: colorScheme),
105+
child: Material(
106+
elevation: 4,
107+
shape: RoundedRectangleBorder(
108+
side: BorderSide(color: Theme.of(context).dividerColor, width: 1.2),
109+
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)),
110110
),
111-
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)),
111+
clipBehavior: Clip.hardEdge,
112+
child: child,
112113
),
113-
clipBehavior: Clip.hardEdge,
114114
);
115115
}
116116

117-
Future<List<String>> headerSuggestionCallback(String pattern) async {
117+
Future<List<String>?> headerSuggestionCallback(String pattern) async {
118+
if (pattern.isEmpty) {
119+
return null;
120+
}
118121
return getHeaderSuggestions(pattern);
119122
}
120123
}

pubspec.lock

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ packages:
306306
dependency: transitive
307307
description:
308308
name: flutter_keyboard_visibility
309-
sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb"
309+
sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8"
310310
url: "https://pub.dev"
311311
source: hosted
312-
version: "5.4.1"
312+
version: "6.0.0"
313313
flutter_keyboard_visibility_linux:
314314
dependency: transitive
315315
description:
@@ -407,10 +407,10 @@ packages:
407407
dependency: "direct main"
408408
description:
409409
name: flutter_typeahead
410-
sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818
410+
sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d
411411
url: "https://pub.dev"
412412
source: hosted
413-
version: "4.8.0"
413+
version: "5.2.0"
414414
flutter_web_plugins:
415415
dependency: transitive
416416
description: flutter
@@ -625,6 +625,30 @@ packages:
625625
url: "https://pub.dev"
626626
source: hosted
627627
version: "0.2.0"
628+
leak_tracker:
629+
dependency: transitive
630+
description:
631+
name: leak_tracker
632+
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
633+
url: "https://pub.dev"
634+
source: hosted
635+
version: "10.0.0"
636+
leak_tracker_flutter_testing:
637+
dependency: transitive
638+
description:
639+
name: leak_tracker_flutter_testing
640+
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
641+
url: "https://pub.dev"
642+
source: hosted
643+
version: "2.0.1"
644+
leak_tracker_testing:
645+
dependency: transitive
646+
description:
647+
name: leak_tracker_testing
648+
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
649+
url: "https://pub.dev"
650+
source: hosted
651+
version: "2.0.1"
628652
lints:
629653
dependency: transitive
630654
description:
@@ -661,26 +685,26 @@ packages:
661685
dependency: transitive
662686
description:
663687
name: matcher
664-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
688+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
665689
url: "https://pub.dev"
666690
source: hosted
667-
version: "0.12.16"
691+
version: "0.12.16+1"
668692
material_color_utilities:
669693
dependency: transitive
670694
description:
671695
name: material_color_utilities
672-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
696+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
673697
url: "https://pub.dev"
674698
source: hosted
675-
version: "0.5.0"
699+
version: "0.8.0"
676700
meta:
677701
dependency: transitive
678702
description:
679703
name: meta
680-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
704+
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
681705
url: "https://pub.dev"
682706
source: hosted
683-
version: "1.10.0"
707+
version: "1.11.0"
684708
mime:
685709
dependency: transitive
686710
description:
@@ -757,10 +781,10 @@ packages:
757781
dependency: "direct main"
758782
description:
759783
name: path
760-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
784+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
761785
url: "https://pub.dev"
762786
source: hosted
763-
version: "1.8.3"
787+
version: "1.9.0"
764788
path_parsing:
765789
dependency: transitive
766790
description:
@@ -853,10 +877,34 @@ packages:
853877
dependency: transitive
854878
description:
855879
name: pointer_interceptor
856-
sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22
880+
sha256: bd18321519718678d5fa98ad3a3359cbc7a31f018554eab80b73d08a7f0c165a
881+
url: "https://pub.dev"
882+
source: hosted
883+
version: "0.10.1"
884+
pointer_interceptor_ios:
885+
dependency: transitive
886+
description:
887+
name: pointer_interceptor_ios
888+
sha256: "2e73c39452830adc4695757130676a39412a3b7f3c34e3f752791b5384770877"
889+
url: "https://pub.dev"
890+
source: hosted
891+
version: "0.10.0+2"
892+
pointer_interceptor_platform_interface:
893+
dependency: transitive
894+
description:
895+
name: pointer_interceptor_platform_interface
896+
sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506"
897+
url: "https://pub.dev"
898+
source: hosted
899+
version: "0.10.0+1"
900+
pointer_interceptor_web:
901+
dependency: transitive
902+
description:
903+
name: pointer_interceptor_web
904+
sha256: "9386e064097fd16419e935c23f08f35b58e6aaec155dd39bd6a003b88f9c14b4"
857905
url: "https://pub.dev"
858906
source: hosted
859-
version: "0.9.3+7"
907+
version: "0.10.1+2"
860908
pointycastle:
861909
dependency: transitive
862910
description:

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dependencies:
4141
json_annotation: ^4.8.1
4242
printing: ^5.11.1
4343
package_info_plus: ^4.1.0
44-
flutter_typeahead: ^4.8.0
44+
flutter_typeahead: ^5.2.0
4545
provider: ^6.0.5
4646
json_data_explorer:
4747
git:

0 commit comments

Comments
 (0)