flutterdata / flutter_data

Seamlessly manage persistent data in your Flutter apps
MIT License
410 stars 31 forks source link

Override or disable pluralization of table names? #168

Closed alguintu closed 2 years ago

alguintu commented 2 years ago

Is there a way to disable pluralization for all tables aside from overriding the urlForFindAll individually for each adapter? I've been searching for a while now but can't find an easy way to do it. Any help would be appreciated. Thanks.

frank06 commented 2 years ago

You should have a generic adapter you apply to all your models and there you can override type (if you don't want to override all of the urlFor* methods)

mixin WhateverAdapter<T extends DataModel<T>> on RemoteAdapter<T> {
  @override
  String get type => super.type.singularize();
}

Does that work?

alguintu commented 2 years ago

I was pretty sure I tried all methods on type yesterday. This works, thank you.