flutterdartflutter-layoutimagepicker

How to remove "image_picker" mark when select image using Image Picker flutter


I have this image picker But when picked the image It shows the "image_pick" mark in front of the image file Like this image_picker5431631000176511341.jpg But I want to remove it How can I do that is it possible?

code:

//Pick image
ElevatedButton(
         onPressed: () => selectFile(),
         child: const Text(
         'Select Image /Gallery'),
        ),

//Show fileName
Text('$fileName')


//To pick image
  void selectFile() async {
    final XFile? results = await picker.pickImage(source: ImageSource.gallery);

    if (results != null) {
      path = results.path;

      fileName = results.name;
      setState(() {});
      print(fileName);
    } else {
      print('No image picked');
    }
    setState(() {
      imageFile = File(results!.path);
    });
  }

Image:

remove the "image_picker" mark in front of the actual file name


Solution

  • change to this

    fileName = results.name.replaceFirst ("image_picker","");