Bläddra i källkod

Fixed null check operator used in null value error

ashilkn 2 år sedan
förälder
incheckning
5426d9ce25
1 ändrade filer med 5 tillägg och 3 borttagningar
  1. 5 3
      lib/ui/components/text_input_widget.dart

+ 5 - 3
lib/ui/components/text_input_widget.dart

@@ -77,9 +77,11 @@ class _TextInputWidgetState extends State<TextInputWidget> {
         selection: TextSelection.collapsed(offset: widget.initialValue!.length),
       );
     }
-    _textController.addListener(() {
-      widget.onChange!.call(_textController.text);
-    });
+    if (widget.onChange != null) {
+      _textController.addListener(() {
+        widget.onChange!.call(_textController.text);
+      });
+    }
     _obscureTextNotifier = ValueNotifier(widget.isPasswordInput);
     _obscureTextNotifier.addListener(_safeRefresh);
     super.initState();