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 { class Localization extends StatelessWidget {
const Localization({ const Localization({
required this.child,
super.key, super.key,
this.child,
}); });
final Widget? child; final Widget child;
@override @override
Widget build(final BuildContext context) => EasyLocalization( Widget build(final BuildContext context) => EasyLocalization(
supportedLocales: const [ supportedLocales: const [
@ -37,6 +38,6 @@ class Localization extends StatelessWidget {
useFallbackTranslations: true, useFallbackTranslations: true,
saveLocale: false, saveLocale: false,
useOnlyLangCode: false, useOnlyLangCode: false,
child: child!, child: child,
); );
} }

View file

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

View file

@ -475,7 +475,7 @@ class ServerInstallationRepository {
Future<void> deleteServerDetails() async { Future<void> deleteServerDetails() async {
await box.delete(BNames.serverDetails); await box.delete(BNames.serverDetails);
getIt<ApiConfigModel>().init(); await getIt<ApiConfigModel>().init();
} }
Future<void> saveServerProviderType(final ServerProviderType type) async { 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 isServerCreated => serverDetails != null;
bool get isFullyInitialized => bool get isFullyInitialized =>
_fulfillmentList.every((final el) => el == true); _fulfillmentList.every((final el) => el ?? false);
ServerSetupProgress get progress => ServerSetupProgress ServerSetupProgress get progress => ServerSetupProgress
.values[_fulfillmentList.where((final el) => el!).length]; .values[_fulfillmentList.where((final el) => el!).length];

View file

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

View file

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

View file

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