Skip to content
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

Warning on change value #44

Open
gilvangobbato opened this issue Oct 18, 2019 · 2 comments
Open

Warning on change value #44

gilvangobbato opened this issue Oct 18, 2019 · 2 comments

Comments

@gilvangobbato
Copy link

I'm getting this warnings on change value

W/IInputConnectionWrapper( 9729): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 9729): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 9729): getTextAfterCursor on inactive InputConnection

This is my code

import 'package:flutter/material.dart';
import 'package:flutter_masked_text/flutter_masked_text.dart';

class InputRealField extends StatelessWidget {
  final IconData icon;
  final String hint;
  final String label;
  final bool obscure;
  final bool enable;
  final Stream<double> stream;
  final Function(double) onChanged;
  final dynamic initialData;
  final MoneyMaskedTextController _controller = new MoneyMaskedTextController(
      decimalSeparator: ',',
      thousandSeparator: '.',
      leftSymbol: "R\$ ",
      precision: 2);
  final bool alwaysCursorInEnd;

  InputRealField(
      {Key key,
      this.icon,
      this.hint,
      this.obscure = false,
      this.enable = true,
      this.stream,
      this.label,
      this.onChanged,
      this.initialData,
      this.alwaysCursorInEnd = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    _controller.addListener(_onChangeValue);
    return StreamBuilder(
        stream: this.stream,
        initialData: initialData,
        builder: (context, snapshot) {
          _controller.updateValue(snapshot.data);
          if (alwaysCursorInEnd) {
            _controller.selection = new TextSelection(
                baseOffset: _controller.value.text.length,
                extentOffset: _controller.value.text.length);
          }
          return TextField(
            enabled: this.enable,
            enableInteractiveSelection: false,
            autofocus: false,
            keyboardType: TextInputType.number,
            decoration: InputDecoration(
                labelText: this.label,
                hintText: this.hint,
                errorText: snapshot.hasError ? snapshot.error : null),
            obscureText: this.obscure,
            controller: _controller,
          );
        });
  }

  void _onChangeValue() {
    onChanged(_controller.numberValue);
  }
}
@naccio8
Copy link

naccio8 commented Oct 29, 2019

It also happens to me and nothing is put in TextField.
I also receive other error:

W/IInputConnectionWrapper( 3560): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 3560): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 3560): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 3560): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 3560): endBatchEdit on inactive InputConnection

@naccio8
Copy link

naccio8 commented Oct 29, 2019

I have found the problem, In my case I define more time the controller, In your case I think that is because you set the controller value in a stream builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants