role_info_handler.dart
894 Bytes
import 'package:appframe/config/locator.dart';
import 'package:appframe/services/dispatcher.dart';
import 'package:shared_preferences/shared_preferences.dart';
class RoleInfoHandler extends MessageHandler {
@override
Future<bool> handleMessage(params) async {
if (params is! Map<String, dynamic>) {
throw Exception('参数错误');
}
final String userId = params['userId'] as String;
final String classCode = params['classCode'] as String;
final int userType = params['userType'] as int;
final String stuId = params['stuId'] as String ?? '';
var sharedPreferences = getIt.get<SharedPreferences>();
sharedPreferences.setString('auth_userCode', userId);
sharedPreferences.setString('auth_classCode', classCode);
sharedPreferences.setInt('auth_userType', userType);
sharedPreferences.setString('auth_stuId', stuId);
return true;
}
}