【发布时间】:2021-08-18 21:02:08
【问题描述】:
我已使用 Firebase 设置推送通知。
发生故障,错误消息不清楚
FormatException:输入意外结束(在字符 1 处) 强文本
我使用 Bloc
class PushNotificationsBloc
extends Bloc<PushNotificationsEvent, PushNotificationsState> {
final UserDataRepository userDataRepository;
PushNotificationsBloc({this.userDataRepository})
: super(PushNotificationsInitial());
@override
Stream<PushNotificationsState> mapEventToState(
PushNotificationsEvent event,
) async* {
if (event is SendNewNotification) {
yield* mapSendNewNotificationToState(event.map);
}
}
Stream<PushNotificationsState> mapSendNewNotificationToState(Map map) async* {
yield SendNewNotificationInProgressState();
try {
String res = await userDataRepository.sendNewNotification(map);
if (res != null) {
yield SendNewNotificationCompletedState(res);
} else {
yield SendNewNotificationFailedState();
}
} catch (e) {
print(e);
yield SendNewNotificationFailedState();
}
}
}
【问题讨论】: