-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you return the static setKeyboardActions() or describe how to get equivalent functionality? #59
Comments
Hmm, would be helpful if you add a simple code to reproduce the issue
(minimun code that I could run here) and I will help you.
…On Tue, Dec 17, 2019, 7:38 PM Gary Chang ***@***.***> wrote:
I tried to upgrade to 3.1.2 from 2.1.2 but I need the equivalent of the
old FormKeyboardActions.setKeyboardActions() as my logic for building the
keyboard actions and my adding of the KeyboardActions widget are in
different places. If there is a new way to achieve this with 3.1.2, can you
please describe this in example code as I couldn't find a way to do this.
Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=ABFL3UFHVMFCGQZNM4KQTDTQZFWHRA5CNFSM4J4DR2U2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IBGMD5Q>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3UAYSLFMJMO6LGXTBHTQZFWHRANCNFSM4J4DR2UQ>
.
|
My code is structured the same way as the example code as per 2.1.2 https://pub.dev/packages/keyboard_actions/versions/2.1.2 In particular FormKeyboardActions widget is built in a separate class to where KeyboardActionsConfig is built, because my keyboard fields dynamically change depending on which type of form is being presented to the user. The example code for 2.1.2 gets around this by providing the static method FormKeyboardActions.setKeyboardActions(), which will update the previously built FormKeyboardActionsState with the update config. This is what I use to update the config. I'd just like this method to be put back. I finally got 3.1.2 working by copying the code inside FormKeyboardActions.setKeyboardActions() and putting it into my code (after renaming FormXX to XX). The source code for 3.1.2 keyboard_actions.dart, line 70 sort of refers to this, but it seems incomplete: 3.1.2 as it currently stands doesn't allow for easy update of the config, whereas 2.1.2 did. 3.1.2 also forces the caller to define the config as soon as the KeyboardActions is created in the widget tree, whereas 2.1.2 allow the config to be defined later. |
You just need to rebuild the widget in order to get the new config,
setState
…On Tue, Dec 17, 2019 at 9:24 PM Gary Chang ***@***.***> wrote:
My code is structured the same way as the example code as per 2.1.2
https://pub.dev/packages/keyboard_actions/versions/2.1.2
In particular FormKeyboardActions widget is built in a separate class to
where KeyboardActionsConfig is built, because my keyboard fields
dynamically change depending on which type of form is being presented to
the user. The example code for 2.1.2 gets around this by providing the
static method FormKeyboardActions.setKeyboardActions(), which will update
the previously built FormKeyboardActionsState with the update config. This
is what I use to update the config. I'd just like this method to be put
back. I finally got 3.1.2 working by copying the code inside
FormKeyboardActions.setKeyboardActions() and putting it into my code (after
renaming FormXX to XX).
The source code for 3.1.2 keyboard_actions.dart, line 70 sort of refers to
this, but it seems incomplete:
/// Can be accessed statically via [] and [] to update with the latest and
greatest [KeyboardActionsConfig].
3.1.2 as it currently stands doesn't allow for easy update of the config,
whereas 2.1.2 did. 3.1.2 also forces the caller to define the config as
soon as the KeyboardActions is created in the widget tree, whereas 2.1.2
allow the config to be defined later.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=ABFL3UD77EKE5K6A4GENGA3QZGCWLA5CNFSM4J4DR2U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHEUCZY#issuecomment-566837607>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3UFCHHNXHAJIY3IU353QZGCWLANCNFSM4J4DR2UQ>
.
|
That's not true, as when I build KeyboardActions, I do NOT have my config yet (see example 2.1.2 code - they are in separate classes) so my outer class does not know what keyboard actions to display yet. I need KeyboardActions at the outer level because putting it in the lower level causes sizing and layout issues. Anyway, don't bother as I have found a workaround as mentioned. Your suggestion forces the caller to build the KeyboardActions widget at the same time as the config which is not always possible for more complex use cases. |
+1 |
If you can add a source code in just one file that I could run here, I
could help you.
…On Tue, Dec 17, 2019, 10:28 PM 钟明 ***@***.***> wrote:
+1
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=ABFL3UDP2BKL2NLUPUS3UVDQZGKGHA5CNFSM4J4DR2U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHEXMCQ#issuecomment-566851082>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3UCXFV4CI56SQQ2RJG3QZGKGHANCNFSM4J4DR2UQ>
.
|
` import 'package:flutter/material.dart'; //Full screen //Dialog /// Displays our [FormKeyboardActions] nested in a [AlertDialog]. _launchInDialog(BuildContext context) { class Content extends StatefulWidget { class _ContentState extends State { /// Creates the [KeyboardActionsConfig] to hook up the fields @OverRide
} @OverRide |
Why don't you remove the keyboard actions from here: return Scaffold(
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: Text("Keyboard Actions Sample"),
),
body: Content(),
); and add it inside your @override
Widget build(BuildContext context) {
return KeyboardActions(
config: _buildConfig(context),
child: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
keyboardType: TextInputType.number,
focusNode: _nodeText1,
decoration: InputDecoration(
hintText: "Input Number",
),
), |
As I've mentioned a few times in the thread above, I cannot do that as KeyboardActions widget at the lower level causes layout and placement issues / crashes. I've tried many different configuration of widgets (but either my form gets centered on screen rather than top aligned etc). As I've also mentioned, your solution needs separation between building the widget, and the configuration changing to handle dynamic sets of input fields. |
ok, then your workaround works fine since you can get the state of the
keyboard actions
…On Wed, Dec 18, 2019 at 5:37 PM Gary Chang ***@***.***> wrote:
As I've mentioned a few times in the thread above, I cannot do that as
KeyboardActions widget at the lower level causes layout and placement
issues / crashes. I've tried many different configuration of widgets (but
either my form gets centered on screen rather than top aligned etc). As
I've also mentioned, your solution needs separation between building the
widget, and the configuration changing to handle dynamic sets of input
fields.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=ABFL3UC7T7LQCV3SLEEF7G3QZKQ3BA5CNFSM4J4DR2U2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHHXJ7Y#issuecomment-567244031>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABFL3UBM7DUWKM23RMBE723QZKQ3BANCNFSM4J4DR2UQ>
.
|
I tried to upgrade to 3.1.2 from 2.1.2 but I need the equivalent of the old FormKeyboardActions.setKeyboardActions() as my logic for building the keyboard actions and my adding of the KeyboardActions widget are in different places. If there is a new way to achieve this with 3.1.2, can you please describe this in example code as I couldn't find a way to do this. Thanks.
The text was updated successfully, but these errors were encountered: