fix: minor code tweaks (no functional changes)

This commit is contained in:
Aliaksei Tratseuski 2024-05-15 14:57:52 +04:00
parent 161c5b7fc5
commit 53ea69a000
7 changed files with 21 additions and 20 deletions

View file

@ -3,11 +3,12 @@ import 'package:flutter/material.dart';
class Localization extends StatelessWidget {
const Localization({
required this.child,
super.key,
this.child,
});
final Widget? child;
final Widget child;
@override
Widget build(final BuildContext context) => EasyLocalization(
supportedLocales: const [
@ -37,6 +38,6 @@ class Localization extends StatelessWidget {
useFallbackTranslations: true,
saveLocale: false,
useOnlyLangCode: false,
child: child!,
child: child,
);
}

View file

@ -119,8 +119,9 @@ abstract class GraphQLApiMap {
String token = '';
final serverDetails = getIt<ApiConfigModel>().serverDetails;
if (serverDetails != null) {
token = getIt<ApiConfigModel>().serverDetails!.apiToken;
token = serverDetails.apiToken;
}
return token;
}

View file

@ -475,7 +475,7 @@ class ServerInstallationRepository {
Future<void> deleteServerDetails() async {
await box.delete(BNames.serverDetails);
getIt<ApiConfigModel>().init();
await getIt<ApiConfigModel>().init();
}
Future<void> saveServerProviderType(final ServerProviderType type) async {

View file

@ -50,7 +50,7 @@ abstract class ServerInstallationState extends Equatable {
bool get isServerCreated => serverDetails != null;
bool get isFullyInitialized =>
_fulfillmentList.every((final el) => el == true);
_fulfillmentList.every((final el) => el ?? false);
ServerSetupProgress get progress => ServerSetupProgress
.values[_fulfillmentList.where((final el) => el!).length];

View file

@ -88,7 +88,6 @@ class ApiConfigModel {
}
void clear() {
_localeCode = null;
_serverProviderKey = null;
_dnsProvider = null;
_serverLocation = null;
@ -101,7 +100,7 @@ class ApiConfigModel {
_serverProvider = null;
}
void init() {
Future<void> init() async {
_localeCode = 'en';
_serverProviderKey = _box.get(BNames.hetznerKey);
_serverLocation = _box.get(BNames.serverLocation);

View file

@ -50,7 +50,8 @@ abstract class AppThemeFactory {
static Future<ColorScheme?> _getDynamicColors(final Brightness brightness) {
try {
return DynamicColorPlugin.getCorePalette().then(
(final corePallet) => corePallet?.toColorScheme(brightness: brightness),
(final corePallete) =>
corePallete?.toColorScheme(brightness: brightness),
);
} on PlatformException {
return Future.value(null);

View file

@ -14,17 +14,16 @@ class NewUserPage extends StatelessWidget {
return BlocProvider(
create: (final BuildContext context) {
final jobCubit = context.read<JobsCubit>();
final jobState = jobCubit.state;
final users = <User>[];
users.addAll(context.read<UsersBloc>().state.users);
if (jobState is JobsStateWithJobs) {
final jobs = jobState.clientJobList;
for (final job in jobs) {
if (job is CreateUserJob) {
users.add(job.user);
}
}
}
// final jobsState = jobCubit.state;
// final users = <User>[
// ...context.read<UsersBloc>().state.users,
// if (jobsState is JobsStateWithJobs)
// ...jobsState.clientJobList
// .whereType<CreateUserJob>()
// .map((final job) => job.user),
// ];
return UserFormCubit(
jobsCubit: jobCubit,
fieldFactory: FieldCubitFactory(context),