我拥有完全开发的Android应用程序,因此我决定尝试跨平台开发,到目前为止,Flutter比Xamarin更令人愉悦,但是我现在遇到了障碍。
我想让用户能够读取从我的服务器下载的ePub文件。我遇到了Flutter软件包,但我不清楚如何在容器中向用户显示ePub-https://pub.dartlang.org/packages/epub
除了示例页面上提供的示例/教程之外,我找不到其他示例/教程(该页面有Image包冲突。我通过将包导入行更改为SwingWorker<Boolean, Integer> worker = new SwingWorker<Boolean, Integer>(){
@Override
protected Boolean doInBackground() throws Exception {
ArrayList<Thread> threadList = new ArrayList();
//ips is a list of IP addresses
if (ips.size() == 1){
try {
newPing.executor.execute(newPing.runSystemCommand(ips.get(0),inputArea,Runtime.getRuntime().exec("ping "+ips.get(0)+" -t")));
} catch (IOException | ClassNotFoundException | SQLException | InterruptedException | ExecutionException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
else{
for (String ip : ips) {
System.out.println(ip);
//multiple instances of textarea MultiView are created
MultiView newView = new MultiView();
newView.setTitle("Pinging "+ip);
newView.setVisible(true);
//for each IP address, a thread is created
class Ping extends Thread {
@Override
public void run(){
try {
newPing.executor.execute(newPing.runSystemCommand(ip ,newView.mView,Runtime.getRuntime().exec("ping "+ip)));
try{Thread.sleep(500);
}catch(InterruptedException e){}
} catch (IOException | ClassNotFoundException | SQLException | InterruptedException | ExecutionException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Ping ping = new Ping();
threadList.add(ping);
}
System.out.println(threadList.size());
ArrayList<Callable<Void>> callables = new ArrayList<>();
threadList.forEach((Thread r) -> {
callables.add(toCallable(r));
});
pool.prestartAllCoreThreads();
while (true) {
pool.invokeAll(callables);
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
return null;
}
};
worker.execute();
//threads are converted to callables
private Callable<Void> toCallable(final Thread thread) {
return new Callable<Void>() {
@Override
public Void call() throws Exception {
thread.start();
try{Thread.sleep(1000);}catch(Exception e){}
return null;
}
};
}
来解决了该冲突),然后在其中引用了所有引用'import package:image/image.dart' as image
的主要方法。这可能是另一天要解决的问题,它涉及为丢失的图像添加自定义占位符。
我无法共享我的ePub文件,但是我已经对github仓库中找到的文件进行了测试,https://github.com/orthros/dart-epub/blob/dev/test/hittelOnGoldMines.epub
谢谢
答案 0 :(得分:0)
我发现的唯一资源是https://github.com/pycampers/flutter_pdf_viewer,但目前仅适用于Android。
另一个方法是使用某些JS框架加载Web视图并加载pdf。