bhrott / flutter-masked-text

A masked text for Flutter.

Home Page:https://pub.dartlang.org/packages/flutter_masked_text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blocked input on Samsung devices

flaviup opened this issue · comments

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);
};

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!

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

I found this issue on Flutter Github.

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

@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?

Hi @QkLahpita,

Unfortunately, not yet

This issue has been resolved?

Same problem here. Any updates?

same problem, delay in samsung devices.

same here, delay input in samsung devices's keyboard