-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
loading_cubit.dart
49 lines (39 loc) · 1.31 KB
/
loading_cubit.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'dart:io';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../logs/logs.dart';
import '../../native_platform/native_platform.dart';
import '../../native_platform/src/linux/linux.dart';
part 'loading_state.dart';
class LoadingCubit extends Cubit<LoadingState> {
final NativePlatform nativePlatform;
LoadingCubit()
: nativePlatform = NativePlatform(),
super(const LoadingInitial()) {
checkDependencies();
}
Future<void> checkDependencies() async {
log.v('Checking dependencies..');
// Make sure we are not running under Wayland.
if (Platform.isLinux) {
final sessionType = await (nativePlatform as Linux).sessionType();
switch (sessionType) {
case 'wayland':
emit(const LoadingWaylandError());
return;
case 'x11':
break;
default:
log.e('''
Unable to determine session type. The XDG_SESSION_TYPE environment variable is set to "$sessionType".
Please note that Wayland is not currently supported.''');
}
}
final dependenciesSatisfied = await nativePlatform.checkDependencies();
LoadingState newState;
newState = (dependenciesSatisfied) //
? const LoadingSuccess()
: const LoadingDependencyError();
emit(newState);
}
}