Class 'SliverMultiBoxAdaptorElement' 没有实例方法 'basename'

Class 'SliverMultiBoxAdaptorElement' has no instance method 'basename'

我正在对图像应用照片滤镜,但出现此错误。我不确定如何从 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)

我正在从图库中获取图像作为文件。这是使用 photofilter

过滤图像的代码
/// 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);
    }
  }

您可以通过以下方式检索基本名称:

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