mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
20 lines
654 B
Dart
20 lines
654 B
Dart
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/auth/bloc/login_event.dart';
|
|
import 'package:syncrow_web/pages/auth/bloc/login_state.dart';
|
|
|
|
class LoginBloc extends Bloc<LoginEvent, LoginState> {
|
|
LoginBloc() : super(LoginInitial()) {
|
|
on<LoginButtonPressed>(_onPress);
|
|
}
|
|
|
|
void _onPress(LoginButtonPressed event, Emitter<LoginState> emit) async {
|
|
emit(LoginLoading());
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
if (event.username == 'admin' && event.password == 'password') {
|
|
emit(LoginSuccess());
|
|
} else {
|
|
emit(const LoginFailure(error: 'Invalid credentials'));
|
|
}
|
|
}
|
|
}
|