Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Class 'SliverMultiBoxAdaptorElement' has no instance method 'basename'

I am applying photo filter to an image but getting this error. I am not sure how to get basename from path_provider.

Unhandled Exception: NoSuchMethodError: Class 'SliverMultiBoxAdaptorElement' has no instance method 'basename'.
E/flutter ( 7318): Receiver: Instance of 'SliverMultiBoxAdaptorElement'
E/flutter ( 7318): Tried calling: basename("/data/user/0/com.sample.photo_editor/cache/scaled_image_picker726990504445239643.png")
E/flutter ( 7318): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)

I am getting image from gallery as file. Here is code for filter image using photofilter package

/// apply photo filters to image
  late String fileName;
  List<Filter> filters = presetFiltersList;
  Future getImage(context) async {
    // imageFile = await ImagePicker.pickImage(source: ImageSource.gallery);
    fileName = context.basename(imageFile.path);
    var image = imageLib.decodeImage(imageFile.readAsBytesSync());
    image = imageLib.copyResize(image!, width: 600);
    Map imagefile = await Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => PhotoFilterSelector(
          title: Text("Photo Filter"),
          image: image!,
          filters: presetFiltersList,
          filename: fileName,
          loader: Center(child: CircularProgressIndicator()),
          fit: BoxFit.contain,
        ),
      ),
    );
    if (imagefile != null && imagefile.containsKey('image_filtered')) {
      setState(() {
        imageFile = imagefile['image_filtered'];
      });
      print(imageFile.path);
    }
  }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can retrieve the basename with this:

import 'package:path/path.dart' as path;
path.basename(imageFile.path);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading