bhrott / flutter-masked-text

A masked text for Flutter.
https://pub.dartlang.org/packages/flutter_masked_text
MIT License
276 stars 124 forks source link

Blocked input on Samsung devices #51

Open flaviup opened 4 years ago

flaviup commented 4 years ago

The code below blocks input on Samsung phones:

final mmTextController = MoneyMaskedTextController( decimalSeparator: DecimalSeparator, thousandSeparator: ThousandSeparator, precision: precision, ); mmTextController.afterChange = (String maskedValue, double rawValue) { // the line below blocks any further input on Samsung phones mmTextController.selection = TextSelection.collapsed(offset: mmTextController.text.length); };

Giuliano-Stravini commented 4 years ago

Hey! I have a similar problem. :(

Only in Samsung devices, when trying update the mask, keyboard freezes

I did a example.


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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  MaskedTextController _controller;

  @override
  void initState() {
    _controller = MaskedTextController(mask: "(00) 0000-0000", text: "");
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField(
              keyboardType: TextInputType.number,
              controller: _controller,
              onChanged: (newValue) {
                if (newValue.length >= 15) {
                  _controller.updateMask("(00) 00000-0000");
                } else {
                  _controller.updateMask("(00) 0000-0000");
                }
                _controller.updateText(newValue);
              },
            ),
          ],
        ),
      ),
    );
  }
}

Flutter Dotcor

[√] Flutter (Channel beta, v1.13.6, on Microsoft Windows [versão 10.0.18362.592], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
[√] Chrome - develop for the web
[√] Android Studio (version 3.4)
[√] VS Code (version 1.42.0)
[√] Connected device (3 available)

• No issues found!
Giuliano-Stravini commented 4 years ago

Maybe this issue have associate with this https://github.com/flutter/flutter/issues/42273

Giuliano-Stravini commented 4 years ago

I found this issue on Flutter Github.

@flaviup try change to master channel, maybe resolve your problem

QkLahpita commented 4 years ago

@Giuliano-Stravini hi, I have the same problem (on Samsung Note 8). I'm using Flutter Channel stable, v1.17.0

If I use TextFormField without MoneyMaskedTextController, it will be okay. How can MoneyMaskedTextController cause the lagging? Do you know?

Have you fixed your problem yet?

Giuliano-Stravini commented 4 years ago

Hi @QkLahpita,

Unfortunately, not yet

machadoguilhermebr commented 4 years ago

This issue has been resolved?

zeucxb commented 4 years ago

Same problem here. Any updates?

rodrigorafaeldamaceno commented 4 years ago

same problem, delay in samsung devices.

vcnt1 commented 4 years ago

same here, delay input in samsung devices's keyboard