Skip to content

Commit

Permalink
Update flutter_typeahead to 5.2.0
Browse files Browse the repository at this point in the history
Don't use previous fork.
  • Loading branch information
erdemyerebasmaz committed May 14, 2024
1 parent 7974b9c commit e38709e
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 49 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ PODS:
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- pointer_interceptor_ios (0.0.1):
- Flutter
- PromisesObjC (2.4.0)
- share_plus (0.0.1):
- Flutter
Expand Down Expand Up @@ -206,6 +208,7 @@ DEPENDENCIES:
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- pointer_interceptor_ios (from `.symlinks/plugins/pointer_interceptor_ios/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preference_app_group (from `.symlinks/plugins/shared_preference_app_group/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
Expand Down Expand Up @@ -282,6 +285,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
pointer_interceptor_ios:
:path: ".symlinks/plugins/pointer_interceptor_ios/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preference_app_group:
Expand Down Expand Up @@ -336,6 +341,7 @@ SPEC CHECKSUMS:
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
pointer_interceptor_ios: 9280618c0b2eeb80081a343924aa8ad756c21375
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preference_app_group: 46aee3873e1da581d4904bece9876596d7f66725
Expand Down
89 changes: 53 additions & 36 deletions lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import 'package:flutter_typeahead/flutter_typeahead.dart';
class RestoreForm extends StatefulWidget {
final GlobalKey formKey;
final int currentPage;
final int lastPage;
final List<TextEditingController> textEditingControllers;
final AutovalidateMode autoValidateMode;

const RestoreForm({
required this.formKey,
required this.currentPage,
required this.lastPage,
required this.textEditingControllers,
required this.autoValidateMode,
});
Expand Down Expand Up @@ -46,37 +44,47 @@ class RestoreFormPageState extends State<RestoreForm> {
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(6, (index) {
final itemIndex = index + (6 * (widget.currentPage - 1));
return TypeAheadFormField(
textFieldConfiguration: TextFieldConfiguration(
controller: widget.textEditingControllers[itemIndex],
textInputAction: TextInputAction.next,
onSubmitted: (text) {
widget.textEditingControllers[itemIndex].text = text;
if (itemIndex + 1 < focusNodes.length) {
focusNodes[itemIndex + 1].requestFocus();
}
},
focusNode: focusNodes[itemIndex],
decoration: InputDecoration(
labelText: "${itemIndex + 1}",
),
style: theme.FieldTextStyle.textStyle,
),
autovalidateMode: _autoValidateMode,
validator: (text) => _onValidate(context, text!),
final itemIndex = index + ((widget.currentPage - 1) * 6);
return TypeAheadField(
builder: (context, controller, focusNode) {
return TextFormField(
controller: widget.textEditingControllers[itemIndex],
textInputAction: TextInputAction.next,
focusNode: focusNodes[itemIndex],
decoration: InputDecoration(
labelText: "${itemIndex + 1}",
),
onFieldSubmitted: (text) => _onSelected(itemIndex, text),
style: theme.FieldTextStyle.textStyle,
autovalidateMode: _autoValidateMode,
validator: (text) => _onValidate(context, text!),
);
},
controller: widget.textEditingControllers[itemIndex],
focusNode: focusNodes[itemIndex],
suggestionsCallback: _getSuggestions,
hideOnEmpty: true,
hideOnLoading: true,
autoFlipDirection: true,
suggestionsBoxDecoration: const SuggestionsBoxDecoration(
color: Colors.white,
constraints: BoxConstraints(
minWidth: 180,
maxWidth: 180,
maxHeight: 180,
),
),
decorationBuilder: (context, child) {
return Row(
children: [
Material(
type: MaterialType.card,
elevation: 4,
color: Colors.white,
borderRadius: BorderRadius.circular(8),
child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 180,
maxWidth: 180,
maxHeight: 180,
),
child: child,
),
),
],
);
},
itemBuilder: <BuildContext, String>(context, suggestion) {
return Container(
decoration: const BoxDecoration(
Expand All @@ -96,19 +104,28 @@ class RestoreFormPageState extends State<RestoreForm> {
),
);
},
onSuggestionSelected: <String>(suggestion) {
widget.textEditingControllers[itemIndex].text = suggestion;
if (itemIndex + 1 < focusNodes.length) {
focusNodes[itemIndex + 1].requestFocus();
}
},
autoFlipDirection: true,
autoFlipMinHeight: 180,
onSelected: <String>(suggestion) => _onSelected(itemIndex, suggestion),
);
}),
),
),
);
}

void _onSelected(int itemIndex, String text) {
final currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus && currentFocus.hasFocus) {
FocusManager.instance.primaryFocus?.unfocus();
}

widget.textEditingControllers[itemIndex + ((widget.currentPage - 1) * 6)].text = text;
if (itemIndex + 1 < focusNodes.length / 2) {
focusNodes[itemIndex + ((widget.currentPage - 1) * 6) + 1].requestFocus();
}
}

String? _onValidate(BuildContext context, String text) {
final texts = context.texts();
if (text.isEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class RestoreFormPageState extends State<RestoreFormPage> {
RestoreForm(
formKey: _formKey,
currentPage: widget.currentPage,
lastPage: widget.lastPage,
textEditingControllers: textEditingControllers,
autoValidateMode: _autoValidateMode,
),
Expand Down
47 changes: 39 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,10 @@ packages:
dependency: transitive
description:
name: flutter_keyboard_visibility
sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb"
sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8"
url: "https://pub.dev"
source: hosted
version: "5.4.1"
version: "6.0.0"
flutter_keyboard_visibility_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -714,12 +714,11 @@ packages:
flutter_typeahead:
dependency: "direct main"
description:
path: "."
ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d
resolved-ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d
url: "https://github.com/breez/flutter_typeahead.git"
source: git
version: "4.0.0"
name: flutter_typeahead
sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d
url: "https://pub.dev"
source: hosted
version: "5.2.0"
flutter_web_plugins:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -1239,6 +1238,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pointer_interceptor:
dependency: transitive
description:
name: pointer_interceptor
sha256: d0a8e660d1204eaec5bd34b34cc92174690e076d2e4f893d9d68c486a13b07c4
url: "https://pub.dev"
source: hosted
version: "0.10.1+1"
pointer_interceptor_ios:
dependency: transitive
description:
name: pointer_interceptor_ios
sha256: "2e73c39452830adc4695757130676a39412a3b7f3c34e3f752791b5384770877"
url: "https://pub.dev"
source: hosted
version: "0.10.0+2"
pointer_interceptor_platform_interface:
dependency: transitive
description:
name: pointer_interceptor_platform_interface
sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506"
url: "https://pub.dev"
source: hosted
version: "0.10.0+1"
pointer_interceptor_web:
dependency: transitive
description:
name: pointer_interceptor_web
sha256: a6237528b46c411d8d55cdfad8fcb3269fc4cbb26060b14bff94879165887d1e
url: "https://pub.dev"
source: hosted
version: "0.10.2"
pointycastle:
dependency: transitive
description:
Expand Down
5 changes: 1 addition & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ dependencies:
flutter_rust_bridge: ^1.82.6
flutter_secure_storage: ^9.1.1
flutter_svg: ^2.0.10+1
flutter_typeahead:
git:
url: https://github.com/breez/flutter_typeahead.git
ref: a16aa4deeff1c5e96c6da46da31cb0533f838d8d
flutter_typeahead: ^5.2.0
git_info: ^1.1.2
hex: ^0.2.0
http: ^1.2.1
Expand Down

0 comments on commit e38709e

Please sign in to comment.