shamblett / sporran

A PouchDB like browser application in Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use with Flutter?

lunedam-git opened this issue · comments

Not an issue, but are there any plans to produce a version of Sporran for Flutter? Maybe using SQLite (via sqflite) for persistent storage on iOS and Android ...

Not at present, however should a need for this arise there's no reason why it can't be looked at.

@shamblett With the incredible number of people heading to Flutter, and with the release of its stable release, it's time to go for it and seize this opportunity.

I'm totally new to CouchDB/Sporran - any hints as to what would be needed to get this working in Flutter?

Well, its a Dart web based library, so in theory whatever it takes to convert one of these into a flutter app, I don't use flutter at the mo so I can't answer this question, maybe ask on the flutter dev list for pointers. I'd like to have a go at this myself but at the mo my other packages are taking up my time so I don't know when I'll be able to get round to this. You could have a go of course and see whats needed.

Ok, I've taken a closer look at the internals.

Just to jot down a few thoughts, Flutter compatibility would require decoupling Sporran/SporranDatabase from dart:html and adding a suitable local storage provider (e.g. SQLite as mentioned by @lunedam-git).

That's on the assumption that Wilt is Flutter compatible (given Wilt seems to support server-side Dart via dart:io, that's probably a safe assumption).

A Wilt client can be instantiated as either server side or web side as you say, so I guess were going the same way now with sporran. The web side we can mainly leave, the server side as you suggest should use SQLite, then the user can chose which way he wants to go, as with Wilt. We may need a generic Database API layer that interfaces to SQLite/Lawndart, also I think at the mo sporran waits for a ready signal from the web page load, we would have to look at this mechanism for the server side, otherwise I think we should be OK.

Please does this now support Flutter?

Not that I'm aware of.

@papakay I did start this work at https://github.com/nmfisher/sporran_flutter (which relied on a fork of this repository at
https://github.com/nmfisher/sporran). I vaguely recall getting most of it done but then moving away from CouchDB, so I never got it to stable or did any work on documentation.

Well, I must say that the page at https://pub.dev/packages/sporran is somewhat confusing, since it flags this as Flutter Web compatible. Who should we trust?

I believe this is correct, the package is designed to run in a browser which I believe is what Flutter Web is. Flutter on the other hand is a server side(VM like) framework, this is the part that's missing from Sporran, as being based on PouchDb there is no server side implementation.

Ok, thanks for the clarification. Since I was looking for a CouchDB-client package, I guess I'm fine: in fact I already manage to run a simple Flutter web app to read data from a CouchDB installation.

If you just want couchdb have a look at the 'wilt' package it's both server and browser based. Sporran uses its browser client

Flutter on the other hand is a server side(VM like) framework

???

Client-side framework. For android apps and the like.

Yes but not for a browser, unless you use flutter web.

@papakay I did start this work at https://github.com/nmfisher/sporran_flutter (which relied on a fork of this repository at
https://github.com/nmfisher/sporran). I vaguely recall getting most of it done but then moving away from CouchDB, so I never got it to stable or did any work on documentation.

What did you move to, @nmfisher ? I've got a use case in a Flutter android app where it seems that the only available solution is google firebase. But I don't want to be tied to google, don't want to have to pay on an ongoing basis to use firebase, and want client & server to be open source, with clean database syncing between them. In theory, pouchdb+couchdb looks like the best option.

@ApplySci I ended up with Firebase (mainly because I didn't want the hassle of running my own server at the time), but I'm still leaving the door open to return to PouchDb+CouchDb.

If you want to remain independent of the Google ecosystem and stay open source, it's a really good choice. The only problem is the lack of a Flutter plugin - you could always try and finish my earlier attempt to port shamblett's work, but I do feel that it would be best to write one from scratch. Dart in 2021 is pretty different from Dart in 2013 (when the original plugins were written) and there's probably now a lot of cleaner functionality & structures available for writing a cross-platform plugin from the ground-up.

From memory the CouchDB API is actually quite straightforward, so I don't think it would really be a huge amount of work. If I was ready to move back to CouchDB, this is probably exactly what I'd do (rather than trying to hack around my earlier efforts to port).

If you are not looking to run in the browser and are not looking to use CouchDB then I'd definitely look at starting again, Sporran is a Dart implementation of PouchDB, which from its website -

PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.

PouchDB was created to help web developers build applications that work as well offline as they do online.
It enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.

porting Sporran to not run in a browser or not use CouchDB seems a bit pointless.

PouchDB was created to help web developers build applications that work as well offline as they do online.
It enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.

so that's the very functionality I need. And I've a flutter app, so the pouchdb part needs to be in dart. Which is just what I thought sporran was.

I suspect @nmfisher is right that starting with a blank sheet is now the best way. And I might build a checklist of things to look out for, informed by the sporran source.

I've thought about this off and on since first raising this issue back in 2018 (mainly when I've been involved in CouchDB projects!). If we're talking about building Android and IOS apps using the Flutter framework (which was my wish back then), my thinking leans towards using the IBM Cloudant (IBM Cloudant uses CouchDB at its heart) native SDKs for Android and IOS and creating a Flutter plugin to interact with them. This does rely on the IBM SDKs being compatible with the latest requirements of Android and IOS, of course.

@lunedam-git great idea, but also a bit concerning that the iOS repository hasn't seen a commit since 2019!

Yeah. It is a concern. As I said, it does rely on the IBM SDKs being compatible with the latest requirements of Android and IOS.

porting Sporran to not run in a browser or not use CouchDB seems a bit pointless.

Not sure I understand the first part of that statement.

If you want a mobile or desktop app to run with "offline-first" priority, it would seem the requirements are the same for any client - not just a browser.

Yes, they are but in sporrans case, being a clone of pouchdb both the ability to run in a browser and use CouchDB is really a must. If you want a general 'offline-first' capability as you put it to operate in other environments then fine, but sporran is not a good starting point.

Yes, they are but in sporrans case, being a clone of pouchdb both the
ability to run in a browser and use CouchDB is really a must. If you want a general 'offline-first' capability as you put it to operate in other environments then fine, but sporran is not a good starting point. Hm. If not, what is a good starting point? I'm not aware of anything else that provides sync between local and remote db (couchbase, maybe. Haven't had as good experience with it as pouchdb/couchdb...) rickb

On Wed, Aug 11, 2021 at 1:45 AM Steve Hamblett @.***> wrote: Yes, they are but in sporrans case, being a clone of pouchdb both the ability to run in a browser and use CouchDB is really a must. If you want a general 'offline-first' capability as you put it to operate in other environments then fine, but sporran is not a good starting point. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#14 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHNQRIFZI2C7Q4YP4PGMLT4ITABANCNFSM4ETNWFXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

May be, we should start thinking of creating a library ourselves. Some of us can work together to write a library to work for web and mobile devices. A few experienced ones can create the design and everybody can start working on their own time. Since Flutter is taking hype, and it's a great framework actually, I would love to have the relevant things in line.

Also, Wilt does not support cookie authentication for CouchDB, and it gives us a little overhead because of password hashing every time the user logins.

Looks like IBM have decided to formally end support / development of their Android / IOS SDKs (not that they were actively maintaining them anyway), and don't plan to replace them with anything. So there goes may vague notion of using them in a Flutter plugin...

CouchDB/PouchDB seems to be a good open source alternative to firebase. Making this package support Flutter IOS and Android will be a huge help. But... as pointed by the note in this doc chapter, using CouchDB as DB combined with application server is no longer recommended.

@ApplySci , @mateuscelio, If it's an open source alternative to Firebase that you're after, it may be worth your while taking a look at Appwrite. This has a Flutter SDK and has fewer of the quirks of CouchDB.

Appwrite does not have an offline sync feature (at the time of this writing), which is the killer feature of the Couch/Pouch combo