userFactory property

User Function(App<T> app) userFactory
final

A function that can create a custom User object or subclass for this App. This is usually used to provide custom functions, properties, login methods and such for your own application.

For example:


class MyCustomUser extends User {
  MyCustomUser({super.app});

  void login() async {
    // Contact your server to login.
    changeId(await _apiLogin());
  }
}

void main() {
  App(
    userFactory: (app) => MyCustomUser(app: app),
  ).run();
}

Implementation

final User Function(App<T> app) userFactory;