Home > Software design >  getting issues when i am using path_provider package
getting issues when i am using path_provider package

Time:03-09


import 'dart:convert';
import 'dart:io';

import 'package:path_provider/path_provider.dart';

void setDetails() async {
  final file = File(
      '${(await getApplicationDocumentsDirectory()).path}/local_user.json');
  file.writeAsString(json.encode('hello'));
  print(file.readAsString());
}

I have implemented above code with path provider package. when i run the code then i am getting error like

Error: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
    at Object.throw_ [as throw] (http://localhost:35143/dart_sdk.js:5067:11)
    at MethodChannel._invokeMethod (http://localhost:35143/packages/flutter/src/services/restoration.dart.lib.js:1560:21)
    at _invokeMethod.next (<anonymous>)
    at http://localhost:35143/dart_sdk.js:40571:33
    at _RootZone.runUnary (http://localhost:35143/dart_sdk.js:40441:59)
    at _FutureListener.thenAwait.handleValue (http://localhost:35143/dart_sdk.js:35363:29)
    at handleValueCallback (http://localhost:35143/dart_sdk.js:35931:49)
    at Function._propagateToListeners (http://localhost:35143/dart_sdk.js:35969:17)
    at _Future.new.[_completeWithValue] (http://localhost:35143/dart_sdk.js:35817:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:35143/dart_sdk.js:35838:35)
    at Object._microtaskLoop (http://localhost:35143/dart_sdk.js:40708:13)
    at _startMicrotaskLoop (http://localhost:35143/dart_sdk.js:40714:13)
    at http://localhost:35143/dart_sdk.js:36191:9

CodePudding user response:

I think you are running your code on the web. When I run your code in android it is working fine.

In the path_provider package there is no support for the web that's why when you run you run your code on the web you are getting issues like No implementation found .....

Try running your code on android.

  • Related