diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/README.md b/pkgs/jnigen/example/pdfbox_plugin/example/README.md index 0f471bec6d..25ccda4406 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/README.md +++ b/pkgs/jnigen/example/pdfbox_plugin/example/README.md @@ -10,6 +10,7 @@ On a Linux machine, following commands can be used to run the example applicatio cd .. ## From this folder dart run jnigen --config jnigen.yaml ## Downloads PDFBox JARs and generates bindings. cd example/ +dart run jni:setup flutter run --release ## Opens the files list from home directory ``` diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart index a70d514b4e..b2363cf300 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart @@ -67,8 +67,6 @@ class PDFInfoAppState extends State { final isDir = (await item.stat()).type == FileSystemEntityType.directory; if (item.path.endsWith('.pdf') && !isDir) { pdfs.add(item.path); - } else if (isDir) { - dirs.add(item.path); } } setState(() { @@ -158,9 +156,10 @@ class PDFFileInfo { // Since java.io is not directly available, use package:jni API to // create a java.io.File object. final fileClass = JClass.forName("java/io/File"); - final inputFile = fileClass - .constructorId("(Ljava/lang/String;)V") - .call(fileClass, JObject.type, [filename]); + final fileConstructor = fileClass.constructorId("(Ljava/lang/String;)V"); + final inputFile = fileConstructor( + fileClass, JObject.type, [JString.fromString(filename)]); + // Static method call PDDocument.load -> PDDocument final pdf = PDDocument.load(inputFile)!; // Instance method call getNumberOfPages() -> int