Unable to load asset storage emulated 0 Android data com example projectdesign app files null

0 votes

how to access file path for the image in the app, lets say i upload the image to the app, and want to use same image for editing, it get this error, how to solve it? this is my code after selecting an image from camera or gallery, i declared two var for display and one for supposed to edit image

ElevatedButton(
               onPressed:  ()async {
               // call dialog and get value "camera" or "galery"
               final type = await  _settingModalBottomSheet(context);
               if(type != null){
               // call image pikcer
              final pickedFile = await _openImagePicker(type);
                if(pickedFile !=null){ 
                  final directory = (await getExternalStorageDirectory())!.path;
                 await Directory('$directory/$_image').create(recursive: true);
                 final fullPath =
                 '$directory/$_image/${DateTime.now().millisecondsSinceEpoch}.png';
                  
                   // set here
                   setState(()
                     {
                      _image = pickedFile;  
                      
                      // Uint8List bytes = pickedFile.readAsBytesSync();
                      //  var simage = ImageProvider;
                      //     image= simage; 
                      // List<int> imageBase64 = _image!.readAsBytesSync();
                      // String imageAsString = base64Encode(imageBase64);
                      // Uint8List uint8list = base64.decode(imageAsString);
                      // image = Image.memory(uint8list);   

                      
                      image = fullPath;
                     });
                 }
                }
              },
               child: const Text('Select An Image'),
               )

this is my code for edit paint image

class ImagePainterExample extends StatefulWidget {
  const ImagePainterExample({super.key, required this.image});
  final String? image;

  @override
  // ignore: library_private_types_in_public_api
  _ImagePainterExampleState createState() => _ImagePainterExampleState(image_1: image);
}

class _ImagePainterExampleState extends State<ImagePainterExample> {
  final _imageKey = GlobalKey<ImagePainterState>();
  final _key = GlobalKey<ScaffoldState>();
   _ImagePainterExampleState({required this.image_1});
   String? image_1;

    

  // void saveImage() async {
  //   final image = await _imageKey.currentState?.exportImage();
  //   final directory = (await getApplicationDocumentsDirectory()).path;
  //   await Directory('$directory/sample').create(recursive: true);
  //   final fullPath =
  //       '$directory/sample/${DateTime.now().millisecondsSinceEpoch}.png';
  //   final imgFile = File(fullPath);
  //   imgFile.writeAsBytesSync(image!);
  //   await GallerySaver.saveImage(fullPath, toDcim: true);
  //   // ignore: use_build_context_synchronously
  //   ScaffoldMessenger.of(context).showSnackBar(
  //     SnackBar(
  //       backgroundColor: Colors.grey[700],
  //       padding: const EdgeInsets.only(left: 10),
  //       content: Row(
  //         mainAxisAlignment: MainAxisAlignment.spaceBetween,
  //         children: [
  //           const Text("Image Exported successfully.",
  //               style: TextStyle(color: Colors.white)),
  //           TextButton(
  //             onPressed: () => OpenFile.open(fullPath),
  //             child: Text(
  //               "Open",
  //               style: TextStyle(
  //                 color: Colors.blue[200],
  //               ),
  //             ),
  //           )
  //         ],
  //       ),
  //     ),
  //   );
  // }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _key,
      appBar: AppBar(
        title: const Text("Image Painter Example"),
        // actions: [
        //   IconButton(
        //     icon: const Icon(Icons.save_alt),
        //     onPressed: saveImage,
        //   )
        // ],
      ),
      body: ImagePainter.asset(
      image_1!,
        key: _imageKey,
        scalable: true,
        initialStrokeWidth: 2,
        initialColor: Colors.green,
        initialPaintMode: PaintMode.line,
        placeholderWidget: Text (image_1!),
      ),
    );
  }
  
 
  
  
}

how to solve this?

Apr 17, 2023 in Flutter by sarit
• 1,830 points
1,686 views

1 answer to this question.

0 votes

The error "Unable to load asset storage emulated 0 Android data com example projectdesign app files null" suggests that the file path you are trying to access is incorrect or the file does not exist. To solve this, you need to ensure that the file path is correct and that the file actually exists at that location.

answered Apr 17, 2023 by vinayak

Related Questions In Flutter

0 votes
1 answer

How to log data to the Flutter console?

To log data to the Flutter console ...READ MORE

answered Mar 27, 2023 in Flutter by anonymous
7,173 views
0 votes
1 answer

How to save to local storage using Flutter?

Yes, Flutter has a built-in mechanism for ...READ MORE

answered Mar 28, 2023 in Flutter by Tej
2,246 views
0 votes
1 answer

Flutter Outline Shows "Nothing to show" in android studio

There are a few possible solutions for ...READ MORE

answered Mar 30, 2023 in Flutter by vishalini
3,098 views
0 votes
1 answer

How to convert json data into array in Flutter?

To convert the JSON data into an ...READ MORE

answered Mar 31, 2023 in Flutter by seena
12,487 views
0 votes
1 answer

How do I give text or an image a transparent background using CSS?

In order to ensure that your image ...READ MORE

answered Feb 8, 2022 in HTML by Rahul
• 9,680 points
1,211 views
0 votes
1 answer

How can I change the app display name build with Flutter?

Yes, you can change the app display ...READ MORE

answered Mar 21, 2023 in Flutter by venky
2,557 views
0 votes
1 answer
0 votes
1 answer

3d Model In Flutter with GLB, OBJ, or GLTF file

To integrate a 3D model into Flutter ...READ MORE

answered Apr 13, 2023 in Flutter by pooja
1,826 views
0 votes
1 answer

How to change Android minSdkVersion in Flutter Project?

Yes, you can change the minSdkVersion in ...READ MORE

answered Mar 21, 2023 in Flutter by Tej
10,961 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP