-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
A Cast Error is appearing when you use a numeric keyboard on Numeric TextFields.
Steps to Reproduce
import 'package:flutter/material.dart';
class Prueba extends StatefulWidget {
const Prueba({Key? key}) : super(key: key);
@override
State<Prueba> createState() => _PruebaState();
}
class _PruebaState extends State<Prueba> {
final numController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Test'),
),
body: TextField(
controller: numController,
keyboardType: TextInputType.number
)
);
}
Expected results:
With the Flutter update I started noticing that numeric text boxes get an error when they are empty.
I managed to reduce the code to the minimum expression to identify the source of the error and apparently it is at the moment of defining the keyboard (TextInputType.number)
Actual results:
When I tap the box to enter the number on an Android Physical Device, this is the error that appears on console:
════════ Exception caught by services library ════════
The following _CastError was thrown during method call TextInputClient.performPrivateCommand: Null check operator used on a null value
When the exception was thrown, this was the stack #0 EditableTextState.performPrivateCommand package:flutter/…/widgets/editable_text.dart:2155 #1 TextInput._handleTextInputInvocation package:flutter/…/services/text_input.dart:1821 #2 TextInput._loudlyHandleTextInputInvocation package:flutter/…/services/text_input.dart:1701 #3 MethodChannel._handleAsMethodCall package:flutter/…/services/platform_channel.dart:536 #4 MethodChannel.setMethodCallHandler. package:flutter/…/services/platform_channel.dart:529 #5 _DefaultBinaryMessenger.setMessageHandler. package:flutter/…/services/binding.dart:387 #6 _invoke2 (dart:ui/hooks.dart:186:13) #7 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5) #8 _Channel.push (dart:ui/channel_buffers.dart:132:31) #9 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17) #10 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22) #11 _dispatchPlatformMessage (dart:ui/hooks.dart:89:31) call: MethodCall(TextInputClient.performPrivateCommand, [13, {data: {}, action: Normal_Mode}])
If I don't include a numeric keyboard, the error disappears.
@chance included the following comments in StackOverflow link:
It was good to open an issue for this problem on the flutter channel, another detail that this problem appears on android and samsung devices have an error in 100% of the cases. In version 3.3 there are some very critical problems on the part of flutter, such as the pageview line 455 value being initialized null and causing white screen where there is tabview or pageview.
Line 2155 editable_text: widget.onAppPrivateCommand!(action, data);. Yet another case of a null statement that fails. Interim fix made in flutter code: if(widget.onAppPrivateCommand != null)widget.onAppPrivateCommand!(action, data);.