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
Курсор не смещается вперёд #32
Comments
Какое используется устройство и клавиатура? |
Привет! Нашёл причину. Ввод обнуляется при ререндеринге. Даже если он был вызван изменением состояния соседнего виджета. Это семпл, на котором я проверял. В нём много лишнего, это из проекта, на котором я всё проверяю. Воспроизвести можно: 1. начать ввод в маскируемое поле; 2. нажать на экшон-баттон; 3. продолжить ввод. import 'dart:math';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:flutter/material.dart';
import 'package:flutter_matomo/flutter_matomo.dart';
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
void main() {
runApp(MyApp());
}
///const URL = 'https://topkek.matomo.cloud/matomo.php';
const SITE_ID = 1;
const URL = 'http://10.0.2.2/matomo/matomo.php';
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
String _matomoStatus = 'Starting ...';
static final random = Random();
static final analytics = FirebaseAnalytics();
@override
void initState() {
_initMatomo().then((void x) {
print("matomo is ready");
}).catchError((e) {
print(e.toString());
});
super.initState();
}
Future<void> _initMatomo() async {
_matomoStatus = await FlutterMatomo.initializeTracker(URL, SITE_ID);
setState(() {});
Future.delayed(Duration(seconds: 4), () async {
_matomoStatus =
await FlutterMatomo.trackScreenWithName("Экран", "Просмотр экрана");
setState(() {});
});
Future.delayed(Duration(seconds: 8), () async {
_matomoStatus =
await FlutterMatomo.trackEventWithName("Источник", "Цель", "Тап");
setState(() {});
});
Future.delayed(Duration(seconds: 12), () async {
_matomoStatus = await FlutterMatomo.trackGoal(1);
setState(() {});
});
Future.delayed(Duration(seconds: 16), () async {
_matomoStatus = await FlutterMatomo
.dispatchEvents(); // должно диспетчиться автоматом каждые 30 секунд (в нативе)
setState(() {});
});
}
void _incrementCounter() {
//analytics.setUserProperty(name: null, value: null);
analytics.logEvent(
name: "custom_error",
parameters: {
"type": random.nextInt(100),
"object": [
"listing",
"search",
"detailed",
"pickup",
"return",
"dump"
][random.nextInt(5)]
},
);
analytics.logEvent(
name: "top_kek",
parameters: {
"Тест": "топ кек азаза",
"top": "YXYjLe9d3zRbA155gEMX7CB8bLIdlP8mnVPQFxQrpDN5TbeyiZ"
.substring(0, random.nextInt(49)),
"kek": "YXYjLe9d3zRbA155gEMX7CB8bLIdlP8mnVPQFxQrpDN5TbeyiZ"
.substring(0, random.nextInt(49))
},
);
analytics.logEvent(name: "Критическая_ошибка_в_ДНК");
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Invoke "debug painting" (press "p" in the console, choose the
// "Toggle Debug Paint" action from the Flutter Inspector in Android
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
// to see the wireframe for each widget.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(_matomoStatus),
TextFormField(
inputFormatters: [
MaskTextInputFormatter(
mask: "+# (###) ###-##-##",
)
],
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
} |
Проблема в initialText |
Спасибо за наводку! |
Привет, Сергей!
flutter doctor -v
[√] Flutter (Channel master, 1.22.0-10.0.pre.176, on Microsoft Windows [Version 10.0.19041.508], locale ru-RU)
• Flutter version 1.22.0-10.0.pre.176 at C:\Users\kasim\Documents\flutter
• Framework revision 96ca0e272b (6 hours ago), 2020-09-15 09:02:04 +0100
• Engine revision 7e962ba911
• Dart version 2.10.0 (build 2.10.0-124.0.dev)
описание проблемы
Установил на TextFormField маску телефонного номера из примера. Курсор автоматически не смещается вперёд, а при вводе пробела содержимое очищается.
https://dump.video/i/xmeNBp.mp4
The text was updated successfully, but these errors were encountered: