WidgetExtension Cannot Access json File Created by Flutter

I have a CRUD app built with flutter. Now I want to use Swift to create a widget to show the data at home screen.

I use json to store the data. In the following code if I replace jsonURL with mock json string, everything works well. So I think the problem comes from accessing the local file.

        let sharedContainerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.app.identifier")
        let jsonURL = sharedContainerURL?.appendingPathComponent("things.json")
            

And this is how I create the json file with Dart.

  Future<String> get _localPath async {
    final directory = await getApplicationDocumentsDirectory();

    return directory.path;
  }

  Future<File> get _localFile async {
    final path = await _localPath;
    return File('$path/$storageName.json');
  }

In a nutshell the problem is that the widget cannot access the json file I created in the app storage. Everything works well except the widget.

WidgetExtension Cannot Access json File Created by Flutter
 
 
Q