Loval realm vs Synced Realm

I have some data that I don’t want to sync to the cloud, my first thought is that I can have two instances of realm one that is synced and another that is local, I am using flutter which way do you recommend?

Yes, you can have multiple realm instances in your app, there’s no issue with that.

You can also define which objects sync and which ones don’t. So for example, if you only wanted to sync the Customers Realm objects, when opening a sync it would be this

final config = Configuration.flexibleSync(currentUser, [Customer.schema], path: 'flex.realm');

The advantage of keeping it in a single Realm is you can still perform queries across objects that have relationships - in the above case if you had some non-sync’d objects that were related to the Customers, a query could be built using a single Realm.

Multi-Realm Queries are not permitted

Your implementation will depend on the use case.


how to keep both local on synced in one flexible sync ?

Which “both”? And what direction do you want to go?

Do you want to have two or more Realm files (“both”) or have one Realm file with different objects where some sync and some don’t (how that’s is in the documentation I linked)

If you want to use different Realm Files that also somewhat covered in the documentation - Configure and Open a Realm File. In a nutshell, you set up different configurations for the different Realm files - e.g. different paths or names, objects etc.