Reputation: 30
I have a TextFormField in my code where the user needs to enter a word (in this case an email) but when the application opens this screen it immediately throws an exception and that exception is repeated everytime the user presses the keys on the keyboard
E/MethodChannel#flutter/platform(24591): Failed to handle method call
E/MethodChannel#flutter/platform(24591): java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.app.trust.ITrustManager.isDeviceLocked(int)' on a null object reference
E/MethodChannel#flutter/platform(24591): at android.os.Parcel.readException(Parcel.java:1626)
E/MethodChannel#flutter/platform(24591): at android.os.Parcel.readException(Parcel.java:1573)
E/MethodChannel#flutter/platform(24591): at android.content.IClipboard$Stub$Proxy.hasPrimaryClip(IClipboard.java:233)
E/MethodChannel#flutter/platform(24591): at android.content.ClipboardManager.hasPrimaryClip(ClipboardManager.java:156)
E/MethodChannel#flutter/platform(24591): at io.flutter.plugin.platform.PlatformPlugin.getClipboardData(PlatformPlugin.java:287)
E/MethodChannel#flutter/platform(24591): at io.flutter.plugin.platform.PlatformPlugin.access$700(PlatformPlugin.java:26)
E/MethodChannel#flutter/platform(24591): at io.flutter.plugin.platform.PlatformPlugin$1.getClipboardData(PlatformPlugin.java:85)
E/MethodChannel#flutter/platform(24591): at io.flutter.embedding.engine.systemchannels.PlatformChannel$1.onMethodCall(PlatformChannel.java:141)
E/MethodChannel#flutter/platform(24591): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter/platform(24591): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#flutter/platform(24591): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:693)
E/MethodChannel#flutter/platform(24591): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter/platform(24591): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#flutter/platform(24591): at android.os.Looper.loop(Looper.java:135)
E/MethodChannel#flutter/platform(24591): at android.app.ActivityThread.main(ActivityThread.java:5445)
E/MethodChannel#flutter/platform(24591): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter/platform(24591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/MethodChannel#flutter/platform(24591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
This is the exception that is called, I believe it's because of the TextFormField, because when I comment the code related to that Widget, the exception disappears.
My code for this Widget:
class AuthPageState extends State<AuthPage> {
final formKey = GlobalKey<FormState>();
String _email, _password = "";
@override
Widget build(BuildContext context) {
final emailField = SizedBox(
height: 44.0,
child: TextFormField(
obscureText: false,
onChanged: (val) => _email = val,
autovalidateMode: AutovalidateMode.onUserInteraction,
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
labelText: "Email",
hintText: "Enter Valid Email",
border:
OutlineInputBorder(borderRadius: BorderRadius.circular(5.0)),
)),
);
return Scaffold(
body: Center(
child: Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(36.0),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Form(key: formKey, child: emailField),
],
),
),
),
),
),
);
}
}
Maybe I've added something in the wrong place or I am forgetting something. I'm fairly new to mobile development in Flutter. I don't understand this exception, and so far I haven't found any information about this type of exceptions with TextFormField.
Thank you for your help!
Upvotes: 0
Views: 367