ChalonaApp<T extends ChalonaSession> constructor

ChalonaApp<T extends ChalonaSession>({
  1. required String name,
  2. required String title,
  3. required String host,
  4. required T session,
  5. required Future<ChalonaSocketIO> wsConnect(),
  6. Widget splash(
    1. BuildContext context
    )?,
  7. Widget login(
    1. BuildContext context
    )?,
  8. Widget onErrorLoading(
    1. BuildContext context
    )?,
  9. void onSuccess(
    1. BuildContext context,
    2. String msg
    )?,
  10. void onError(
    1. BuildContext context,
    2. String msg
    )?,
  11. Map<String, Widget Function(BuildContext)> routes = const {},
})

Implementation

ChalonaApp({
  required this.name,
  required this.title,
  required String host,
  required T this.session,
  required super.wsConnect,
  Widget Function(BuildContext context)? splash,
  Widget Function(BuildContext context)? login,
  Widget Function(BuildContext context)? onErrorLoading,
  void Function(BuildContext context, String msg)? onSuccess,
  void Function(BuildContext context, String msg)? onError,
  Map<String, Widget Function(BuildContext)> routes = const {},
})  : _splashScreen = splash ?? _defaultSplash,
      _loginScreen = login ?? _defaultLogin,
      _errorLoadingScreen = onErrorLoading ?? _errorLoadingDefault,
      _success = onSuccess ?? _handleSuccess,
      _error = onError ?? _handleError,
      super(host: ChalonaHttp(host: host), newStates: [
        initializeApp,
        sessionIsRecoveringState,
        sessionIsRecoveredState,
      ]) {
  ChalonaApp._current = this;
  _routes = {
    '/home': (context) => const Scaffold(
          body: Center(
            child: Text('Home'),
          ),
        ),
  };
  for (var k in routes.keys) {
    _routes[k] = routes[k]!;
  }
}