title: The following _CastError was thrown building RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#0cfc0]
body: <p>Hello I am trying to add picture to the APP by image picker But when I close the screen and open it again that message show to me</p>
  <pre><code>════════ Exception caught by widgets library ═══════════════════════════════════
  The following _CastError was thrown building RawGestureDetector-[LabeledGlobalKey&lt;RawGestureDetectorState&gt;#0cfc0](state: RawGestureDetectorState#aaba3(gestures: &lt;none&gt;, behavior: opaque)):
  Null check operator used on a null value
  
  The relevant error-causing widget was
  SingleChildScrollView
  lib\screens\create_post.dart:22
  When the exception was thrown, this was the stack
  </code></pre>
  <p>and that my code of CreatePost Screen</p>
  <pre><code>Scaffold(
          body: SingleChildScrollView(
            child: Column(
              children: [
                Container(
                  height: MediaQuery.of(context).size.height * 0.25,
                  decoration: BoxDecoration(
                    color: primary,
                    borderRadius: BorderRadius.only(
                      bottomLeft: Radius.circular(100),
                    ),
                  ),
                  child: CustomText(
                    text: 'Sell Your Car',
                    alignment: Alignment.center,
                    fontSize: 40,
                  ),
                ),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.05,
                ),
                CustomTextFormFild(onSave: () {}, hint: 'car name'),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.05,
                ),
                CustomTextFormFild(onSave: () {}, hint: 'car description'),
                SizedBox(
                  height: MediaQuery.of(context).size.height * 0.05,
                ),
                GetBuilder&lt;ImageViewModel&gt;(
                  builder: (controller) =&gt; Column(
                    children: [
                      Container(
                        child: CustomButton(
                          onPressed: () {
                            controller.getImage(ImageSource.gallery);
                          },
                          text: 'Upload Image',
                          alignment: Alignment.center,
                        ),
                      ),
                      SizedBox(
                        height: 20,
                      ),
                      controller.selectedImagePath.value == ''
                          ? Text(
                              'Select immage from camera/gallery',
                              style: TextStyle(fontSize: 20),
                            )
                          : Image.file(File(controller.selectedImagePath.value)),
                    ],
                  ),
                )
              ],
            ),
          ),)
  </code></pre>
  <p>and also the controller of the image picker</p>
  <pre><code>class ImageViewModel extends GetxController {
    //TODO: Implement HomeController
  
    var selectedImagePath = ''.obs;
  
    void getImage(ImageSource imageSource) async {
      final pickedFile = await ImagePicker().pickImage(source: imageSource);
  
      if (pickedFile != null) {
        selectedImagePath.value = pickedFile.path;
      } else {
        Get.snackbar(&quot;Error&quot;, &quot;No Image selected&quot;,
            snackPosition: SnackPosition.BOTTOM,
            backgroundColor: Colors.red,
            colorText: Colors.white);
      }
    }
  
    @override
    void onInit() {
      super.onInit();
    }
  
    @override
    void onClose() {}
  }
  </code></pre>
  <p>something went wrong the image should be deleted after i close the screen but that don`t work</p>