Bug fixes and linting

master^2
Inex Code 2022-06-10 00:13:06 +03:00
parent ad53000415
commit 18d0c2c40f
35 changed files with 208 additions and 152 deletions

View File

@ -82,6 +82,7 @@ ThemeData darkTheme = lightTheme.copyWith(
), ),
); );
const EdgeInsets paddingH15V30 = EdgeInsets.symmetric(horizontal: 15, vertical: 30); const EdgeInsets paddingH15V30 =
EdgeInsets.symmetric(horizontal: 15, vertical: 30);
const EdgeInsets paddingH15V0 = EdgeInsets.symmetric(horizontal: 15); const EdgeInsets paddingH15V0 = EdgeInsets.symmetric(horizontal: 15);

View File

@ -25,7 +25,8 @@ class HiveConfig {
await Hive.openBox(BNames.appSettingsBox); await Hive.openBox(BNames.appSettingsBox);
final HiveAesCipher cipher = HiveAesCipher( final HiveAesCipher cipher = HiveAesCipher(
await getEncryptedKey(BNames.serverInstallationEncryptionKey),); await getEncryptedKey(BNames.serverInstallationEncryptionKey),
);
await Hive.openBox<User>(BNames.usersDeprecated); await Hive.openBox<User>(BNames.usersDeprecated);
await Hive.openBox<User>(BNames.usersBox, encryptionCipher: cipher); await Hive.openBox<User>(BNames.usersBox, encryptionCipher: cipher);

View File

@ -63,9 +63,11 @@ final TextStyle buttonTitleText = defaultTextStyle.copyWith(
height: 1, height: 1,
); );
final TextStyle mediumStyle = defaultTextStyle.copyWith(fontSize: 13, height: 1.53); final TextStyle mediumStyle =
defaultTextStyle.copyWith(fontSize: 13, height: 1.53);
final TextStyle smallStyle = defaultTextStyle.copyWith(fontSize: 11, height: 1.45); final TextStyle smallStyle =
defaultTextStyle.copyWith(fontSize: 11, height: 1.45);
const TextStyle progressTextStyleLight = TextStyle( const TextStyle progressTextStyleLight = TextStyle(
fontSize: 11, fontSize: 11,

View File

@ -61,7 +61,6 @@ class Loading extends DomainSetupState {
enum LoadingTypes { loadingDomain, saving } enum LoadingTypes { loadingDomain, saving }
class Loaded extends DomainSetupState { class Loaded extends DomainSetupState {
Loaded(this.domain); Loaded(this.domain);
final String domain; final String domain;
} }

View File

@ -12,7 +12,8 @@ class ProvidersCubit extends Cubit<ProvidersState> {
ProvidersCubit() : super(InitialProviderState()); ProvidersCubit() : super(InitialProviderState());
void connect(final ProviderModel provider) { void connect(final ProviderModel provider) {
final ProvidersState newState = state.updateElement(provider, StateType.stable); final ProvidersState newState =
state.updateElement(provider, StateType.stable);
emit(newState); emit(newState);
} }
} }

View File

@ -19,8 +19,12 @@ class RecoveryKeyCubit
if (status == null) { if (status == null) {
emit(state.copyWith(loadingStatus: LoadingStatus.error)); emit(state.copyWith(loadingStatus: LoadingStatus.error));
} else { } else {
emit(state.copyWith( emit(
status: status, loadingStatus: LoadingStatus.success,),); state.copyWith(
status: status,
loadingStatus: LoadingStatus.success,
),
);
} }
} else { } else {
emit(state.copyWith(loadingStatus: LoadingStatus.uninitialized)); emit(state.copyWith(loadingStatus: LoadingStatus.uninitialized));
@ -44,7 +48,8 @@ class RecoveryKeyCubit
emit(state.copyWith(loadingStatus: LoadingStatus.error)); emit(state.copyWith(loadingStatus: LoadingStatus.error));
} else { } else {
emit( emit(
state.copyWith(status: status, loadingStatus: LoadingStatus.success),); state.copyWith(status: status, loadingStatus: LoadingStatus.success),
);
} }
} }
@ -69,7 +74,6 @@ class RecoveryKeyCubit
} }
class GenerationError extends Error { class GenerationError extends Error {
GenerationError(this.message); GenerationError(this.message);
final String message; final String message;
} }

View File

@ -18,12 +18,14 @@ class ServerDetailsCubit extends Cubit<ServerDetailsState> {
if (isReadyToCheck) { if (isReadyToCheck) {
emit(ServerDetailsLoading()); emit(ServerDetailsLoading());
final ServerDetailsRepositoryDto data = await repository.load(); final ServerDetailsRepositoryDto data = await repository.load();
emit(Loaded( emit(
serverInfo: data.hetznerServerInfo, Loaded(
autoUpgradeSettings: data.autoUpgradeSettings, serverInfo: data.hetznerServerInfo,
serverTimezone: data.serverTimezone, autoUpgradeSettings: data.autoUpgradeSettings,
checkTime: DateTime.now(), serverTimezone: data.serverTimezone,
),); checkTime: DateTime.now(),
),
);
} else { } else {
emit(ServerDetailsNotReady()); emit(ServerDetailsNotReady());
} }

View File

@ -19,7 +19,6 @@ class ServerDetailsRepository {
} }
class ServerDetailsRepositoryDto { class ServerDetailsRepositoryDto {
ServerDetailsRepositoryDto({ ServerDetailsRepositoryDto({
required this.hetznerServerInfo, required this.hetznerServerInfo,
required this.serverTimezone, required this.serverTimezone,

View File

@ -146,8 +146,9 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
} }
void startServerIfDnsIsOkay( void startServerIfDnsIsOkay({
{final ServerInstallationNotFinished? state,}) async { final ServerInstallationNotFinished? state,
}) async {
final ServerInstallationNotFinished dataState = final ServerInstallationNotFinished dataState =
state ?? this.state as ServerInstallationNotFinished; state ?? this.state as ServerInstallationNotFinished;
@ -345,7 +346,9 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void tryToRecover( void tryToRecover(
final String token, final ServerRecoveryMethods method,) async { final String token,
final ServerRecoveryMethods method,
) async {
final ServerInstallationRecovery dataState = final ServerInstallationRecovery dataState =
state as ServerInstallationRecovery; state as ServerInstallationRecovery;
final ServerDomain? serverDomain = dataState.serverDomain; final ServerDomain? serverDomain = dataState.serverDomain;
@ -395,6 +398,9 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void revertRecoveryStep() { void revertRecoveryStep() {
if (state is ServerInstallationEmpty) {
return;
}
final ServerInstallationRecovery dataState = final ServerInstallationRecovery dataState =
state as ServerInstallationRecovery; state as ServerInstallationRecovery;
switch (dataState.currentStep) { switch (dataState.currentStep) {
@ -535,7 +541,8 @@ class ServerInstallationCubit extends Cubit<ServerInstallationState> {
} }
void finishRecoveryProcess( void finishRecoveryProcess(
final BackblazeCredential backblazeCredential,) async { final BackblazeCredential backblazeCredential,
) async {
await repository.saveIsServerStarted(true); await repository.saveIsServerStarted(true);
await repository.saveIsServerResetedFirstTime(true); await repository.saveIsServerResetedFirstTime(true);
await repository.saveIsServerResetedSecondTime(true); await repository.saveIsServerResetedSecondTime(true);

View File

@ -4,11 +4,12 @@ part 'backblaze_bucket.g.dart';
@HiveType(typeId: 6) @HiveType(typeId: 6)
class BackblazeBucket { class BackblazeBucket {
BackblazeBucket( BackblazeBucket({
{required this.bucketId, required this.bucketId,
required this.bucketName, required this.bucketName,
required this.applicationKeyId, required this.applicationKeyId,
required this.applicationKey,}); required this.applicationKey,
});
@HiveField(0) @HiveField(0)
final String bucketId; final String bucketId;

View File

@ -35,15 +35,16 @@ class ServerHostingDetails {
@HiveField(6, defaultValue: ServerProvider.hetzner) @HiveField(6, defaultValue: ServerProvider.hetzner)
final ServerProvider provider; final ServerProvider provider;
ServerHostingDetails copyWith({final DateTime? startTime}) => ServerHostingDetails( ServerHostingDetails copyWith({final DateTime? startTime}) =>
startTime: startTime ?? this.startTime, ServerHostingDetails(
createTime: createTime, startTime: startTime ?? this.startTime,
id: id, createTime: createTime,
ip4: ip4, id: id,
volume: volume, ip4: ip4,
apiToken: apiToken, volume: volume,
provider: provider, apiToken: apiToken,
); provider: provider,
);
@override @override
String toString() => id.toString(); String toString() => id.toString();

View File

@ -4,7 +4,6 @@ part 'api_token.g.dart';
@JsonSerializable() @JsonSerializable()
class ApiToken { class ApiToken {
factory ApiToken.fromJson(final Map<String, dynamic> json) => factory ApiToken.fromJson(final Map<String, dynamic> json) =>
_$ApiTokenFromJson(json); _$ApiTokenFromJson(json);
ApiToken({ ApiToken({

View File

@ -4,8 +4,8 @@ part 'backup.g.dart';
@JsonSerializable() @JsonSerializable()
class Backup { class Backup {
factory Backup.fromJson(final Map<String, dynamic> json) =>
factory Backup.fromJson(final Map<String, dynamic> json) => _$BackupFromJson(json); _$BackupFromJson(json);
Backup({required this.time, required this.id}); Backup({required this.time, required this.id});
// Time of the backup // Time of the backup
@ -33,13 +33,13 @@ enum BackupStatusEnum {
@JsonSerializable() @JsonSerializable()
class BackupStatus { class BackupStatus {
factory BackupStatus.fromJson(final Map<String, dynamic> json) => factory BackupStatus.fromJson(final Map<String, dynamic> json) =>
_$BackupStatusFromJson(json); _$BackupStatusFromJson(json);
BackupStatus( BackupStatus({
{required this.status, required this.status,
required this.progress, required this.progress,
required this.errorMessage,}); required this.errorMessage,
});
final BackupStatusEnum status; final BackupStatusEnum status;
final double progress; final double progress;

View File

@ -4,7 +4,6 @@ part 'device_token.g.dart';
@JsonSerializable() @JsonSerializable()
class DeviceToken { class DeviceToken {
factory DeviceToken.fromJson(final Map<String, dynamic> json) => factory DeviceToken.fromJson(final Map<String, dynamic> json) =>
_$DeviceTokenFromJson(json); _$DeviceTokenFromJson(json);
DeviceToken({ DeviceToken({

View File

@ -1,5 +1,4 @@
class ServerStatus { class ServerStatus {
ServerStatus({ ServerStatus({
required this.http, required this.http,
this.imap = StatusTypes.nodata, this.imap = StatusTypes.nodata,
@ -10,10 +9,10 @@ class ServerStatus {
final StatusTypes smtp; final StatusTypes smtp;
ServerStatus fromJson(final Map<String, dynamic> json) => ServerStatus( ServerStatus fromJson(final Map<String, dynamic> json) => ServerStatus(
http: statusTypeFromNumber(json['http']), http: statusTypeFromNumber(json['http']),
imap: statusTypeFromNumber(json['imap']), imap: statusTypeFromNumber(json['imap']),
smtp: statusTypeFromNumber(json['smtp']), smtp: statusTypeFromNumber(json['smtp']),
); );
} }
StatusTypes statusTypeFromNumber(final int? number) { StatusTypes statusTypeFromNumber(final int? number) {

View File

@ -55,7 +55,7 @@ class _BrandMarkdownState extends State<BrandMarkdown> {
color: isDark ? BrandColors.white : null, color: isDark ? BrandColors.white : null,
), ),
); );
return Markdown( return MarkdownBody(
shrinkWrap: true, shrinkWrap: true,
styleSheet: markdown, styleSheet: markdown,
onTapLink: (final String text, final String? href, final String title) { onTapLink: (final String text, final String? href, final String title) {

View File

@ -8,19 +8,19 @@ class BrandError extends StatelessWidget {
@override @override
Widget build(final BuildContext context) => SafeArea( Widget build(final BuildContext context) => SafeArea(
child: Scaffold( child: Scaffold(
body: Center( body: Center(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text(error.toString()), Text(error.toString()),
const Text('stackTrace: '), const Text('stackTrace: '),
Text(stackTrace.toString()), Text(stackTrace.toString()),
], ],
),
), ),
), ),
), ),
), );
);
} }

View File

@ -66,7 +66,7 @@ class _KeyDisplay extends StatelessWidget {
const SizedBox(height: 16), const SizedBox(height: 16),
Text( Text(
'devices.add_new_device_screen.tip'.tr(), 'devices.add_new_device_screen.tip'.tr(),
style: Theme.of(context).textTheme.bodyMedium!, style: Theme.of(context).textTheme.bodyMedium,
), ),
], ],
), ),

View File

@ -234,7 +234,9 @@ class _RecoveryKeyConfigurationState extends State<RecoveryKeyConfiguration> {
: null, : null,
expirationDate: _isExpirationToggled ? _selectedDate : null, expirationDate: _isExpirationToggled ? _selectedDate : null,
); );
if (!mounted) return; if (!mounted) {
return;
}
setState(() { setState(() {
_isLoading = false; _isLoading = false;
}); });

View File

@ -8,11 +8,11 @@ import 'package:intl/intl.dart';
class CpuChart extends StatelessWidget { class CpuChart extends StatelessWidget {
const CpuChart({ const CpuChart({
final Key? key,
required this.data, required this.data,
required this.period, required this.period,
required this.start, required this.start,
}) : super(key: key); final super.key,
});
final List<TimeSeriesData> data; final List<TimeSeriesData> data;
final Period period; final Period period;

View File

@ -10,11 +10,11 @@ import 'package:intl/intl.dart';
class NetworkChart extends StatelessWidget { class NetworkChart extends StatelessWidget {
const NetworkChart({ const NetworkChart({
final Key? key,
required this.listData, required this.listData,
required this.period, required this.period,
required this.start, required this.start,
}) : super(key: key); final super.key,
});
final List<List<TimeSeriesData>> listData; final List<List<TimeSeriesData>> listData;
final Period period; final Period period;

View File

@ -567,8 +567,13 @@ class _HowTo extends StatelessWidget {
isExpended: true, isExpended: true,
child: Padding( child: Padding(
padding: paddingH15V0, padding: paddingH15V0,
child: BrandMarkdown( child: ListView(
fileName: fileName, padding: const EdgeInsets.symmetric(vertical: 16),
children: [
BrandMarkdown(
fileName: fileName,
),
],
), ),
), ),
); );

View File

@ -17,8 +17,8 @@ class RecoverByNewDeviceKeyInstruction extends StatelessWidget {
heroSubtitle: 'recovering.method_device_description'.tr(), heroSubtitle: 'recovering.method_device_description'.tr(),
hasBackButton: true, hasBackButton: true,
hasFlashButton: false, hasFlashButton: false,
onBackButtonPressed: () => onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep(), context.read<ServerInstallationCubit>().revertRecoveryStep,
children: [ children: [
FilledButton( FilledButton(
title: 'recovering.method_device_button'.tr(), title: 'recovering.method_device_button'.tr(),

View File

@ -28,8 +28,8 @@ class RecoverByOldTokenInstruction extends StatelessWidget {
heroTitle: 'recovering.recovery_main_header'.tr(), heroTitle: 'recovering.recovery_main_header'.tr(),
hasBackButton: true, hasBackButton: true,
hasFlashButton: false, hasFlashButton: false,
onBackButtonPressed: () => onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep(), context.read<ServerInstallationCubit>().revertRecoveryStep,
children: [ children: [
BrandMarkdown( BrandMarkdown(
fileName: instructionFilename, fileName: instructionFilename,

View File

@ -31,8 +31,8 @@ class RecoverByRecoveryKey extends StatelessWidget {
heroSubtitle: 'recovering.method_recovery_input_description'.tr(), heroSubtitle: 'recovering.method_recovery_input_description'.tr(),
hasBackButton: true, hasBackButton: true,
hasFlashButton: false, hasFlashButton: false,
onBackButtonPressed: () => onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep(), context.read<ServerInstallationCubit>().revertRecoveryStep,
children: [ children: [
CubitFormTextField( CubitFormTextField(
formFieldCubit: formFieldCubit:

View File

@ -10,7 +10,7 @@ import 'package:selfprivacy/ui/components/brand_hero_screen/brand_hero_screen.da
import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart';
class RecoveryConfirmBackblaze extends StatelessWidget { class RecoveryConfirmBackblaze extends StatelessWidget {
const RecoveryConfirmBackblaze({final Key? key}) : super(key: key); const RecoveryConfirmBackblaze({final super.key});
@override @override
Widget build(final BuildContext context) { Widget build(final BuildContext context) {
@ -59,13 +59,17 @@ class RecoveryConfirmBackblaze extends StatelessWidget {
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (final BuildContext context) => builder: (final BuildContext context) => BrandBottomSheet(
const BrandBottomSheet(
isExpended: true, isExpended: true,
child: Padding( child: Padding(
padding: paddingH15V0, padding: paddingH15V0,
child: BrandMarkdown( child: ListView(
fileName: 'how_backblaze', padding: const EdgeInsets.symmetric(vertical: 16),
children: const [
BrandMarkdown(
fileName: 'how_backblaze',
),
],
), ),
), ),
), ),

View File

@ -52,13 +52,17 @@ class RecoveryConfirmCloudflare extends StatelessWidget {
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (final BuildContext context) => builder: (final BuildContext context) => BrandBottomSheet(
const BrandBottomSheet(
isExpended: true, isExpended: true,
child: Padding( child: Padding(
padding: paddingH15V0, padding: paddingH15V0,
child: BrandMarkdown( child: ListView(
fileName: 'how_cloudflare', padding: const EdgeInsets.symmetric(vertical: 16),
children: const [
BrandMarkdown(
fileName: 'how_cloudflare',
),
],
), ),
), ),
), ),

View File

@ -54,13 +54,17 @@ class RecoveryHetznerConnected extends StatelessWidget {
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (final BuildContext context) => builder: (final BuildContext context) => BrandBottomSheet(
const BrandBottomSheet(
isExpended: true, isExpended: true,
child: Padding( child: Padding(
padding: paddingH15V0, padding: paddingH15V0,
child: BrandMarkdown( child: ListView(
fileName: 'how_hetzner', padding: const EdgeInsets.symmetric(vertical: 16),
children: const [
BrandMarkdown(
fileName: 'how_hetzner',
),
],
), ),
), ),
), ),

View File

@ -17,6 +17,8 @@ class RecoveryMethodSelect extends StatelessWidget {
heroSubtitle: 'recovering.method_select_description'.tr(), heroSubtitle: 'recovering.method_select_description'.tr(),
hasBackButton: true, hasBackButton: true,
hasFlashButton: false, hasFlashButton: false,
onBackButtonPressed:
context.read<ServerInstallationCubit>().revertRecoveryStep,
children: [ children: [
BrandCards.outlined( BrandCards.outlined(
child: ListTile( child: ListTile(

View File

@ -108,10 +108,6 @@ class SelectDomainToRecover extends StatelessWidget {
heroSubtitle: 'recovering.domain_recovery_description'.tr(), heroSubtitle: 'recovering.domain_recovery_description'.tr(),
hasBackButton: true, hasBackButton: true,
hasFlashButton: false, hasFlashButton: false,
onBackButtonPressed:
serverInstallation is ServerInstallationRecovery
? serverInstallation.clearAppConfig
: null,
children: [ children: [
CubitFormTextField( CubitFormTextField(
formFieldCubit: formFieldCubit:

View File

@ -2,10 +2,9 @@ part of 'users.dart';
class _UserDetails extends StatelessWidget { class _UserDetails extends StatelessWidget {
const _UserDetails({ const _UserDetails({
final Key? key,
required this.user, required this.user,
required this.isRootUser, required this.isRootUser,
}) : super(key: key); });
final User user; final User user;
final bool isRootUser; final bool isRootUser;

View File

@ -32,7 +32,9 @@ extension TextExtension on Text {
final String? semanticsLabel, final String? semanticsLabel,
final TextWidthBasis? textWidthBasis, final TextWidthBasis? textWidthBasis,
final TextStyle? style, final TextStyle? style,
}) => Text(data!, }) =>
Text(
data!,
key: key ?? this.key, key: key ?? this.key,
strutStyle: strutStyle ?? this.strutStyle, strutStyle: strutStyle ?? this.strutStyle,
textAlign: textAlign ?? this.textAlign, textAlign: textAlign ?? this.textAlign,
@ -44,5 +46,6 @@ extension TextExtension on Text {
maxLines: maxLines ?? this.maxLines, maxLines: maxLines ?? this.maxLines,
semanticsLabel: semanticsLabel ?? this.semanticsLabel, semanticsLabel: semanticsLabel ?? this.semanticsLabel,
textWidthBasis: textWidthBasis ?? this.textWidthBasis, textWidthBasis: textWidthBasis ?? this.textWidthBasis,
style: style != null ? this.style?.merge(style) ?? style : this.style,); style: style != null ? this.style?.merge(style) ?? style : this.style,
);
} }

View File

@ -12,24 +12,25 @@ Function transitionsBuilder = (
final Animation<double> animation, final Animation<double> animation,
final Animation<double> secondaryAnimation, final Animation<double> secondaryAnimation,
final Widget child, final Widget child,
) => SlideTransition( ) =>
position: Tween<Offset>( SlideTransition(
begin: const Offset(0, 1), position: Tween<Offset>(
end: Offset.zero, begin: const Offset(0, 1),
).animate(animation), end: Offset.zero,
child: Container( ).animate(animation),
decoration: animation.isCompleted child: Container(
? null decoration: animation.isCompleted
: const BoxDecoration( ? null
border: Border( : const BoxDecoration(
bottom: BorderSide( border: Border(
color: Colors.black, bottom: BorderSide(
color: Colors.black,
),
), ),
), ),
), child: child,
child: child, ),
), );
);
class SlideBottomRoute extends PageRouteBuilder { class SlideBottomRoute extends PageRouteBuilder {
SlideBottomRoute(this.widget) SlideBottomRoute(this.widget)
@ -37,7 +38,11 @@ class SlideBottomRoute extends PageRouteBuilder {
transitionDuration: const Duration(milliseconds: 150), transitionDuration: const Duration(milliseconds: 150),
pageBuilder: pageBuilder(widget), pageBuilder: pageBuilder(widget),
transitionsBuilder: transitionsBuilder as Widget Function( transitionsBuilder: transitionsBuilder as Widget Function(
BuildContext, Animation<double>, Animation<double>, Widget,), BuildContext,
Animation<double>,
Animation<double>,
Widget,
),
); );
final Widget widget; final Widget widget;

View File

@ -12,31 +12,36 @@ Function transitionsBuilder = (
final Animation<double> animation, final Animation<double> animation,
final Animation<double> secondaryAnimation, final Animation<double> secondaryAnimation,
final Widget child, final Widget child,
) => SlideTransition( ) =>
position: Tween<Offset>( SlideTransition(
begin: const Offset(-1, 0), position: Tween<Offset>(
end: Offset.zero, begin: const Offset(-1, 0),
).animate(animation), end: Offset.zero,
child: Container( ).animate(animation),
decoration: animation.isCompleted child: Container(
? null decoration: animation.isCompleted
: const BoxDecoration( ? null
border: Border( : const BoxDecoration(
right: BorderSide( border: Border(
color: Colors.black, right: BorderSide(
color: Colors.black,
),
), ),
), ),
), child: child,
child: child, ),
), );
);
class SlideRightRoute extends PageRouteBuilder { class SlideRightRoute extends PageRouteBuilder {
SlideRightRoute(this.widget) SlideRightRoute(this.widget)
: super( : super(
pageBuilder: pageBuilder(widget), pageBuilder: pageBuilder(widget),
transitionsBuilder: transitionsBuilder as Widget Function( transitionsBuilder: transitionsBuilder as Widget Function(
BuildContext, Animation<double>, Animation<double>, Widget,), BuildContext,
Animation<double>,
Animation<double>,
Widget,
),
); );
final Widget widget; final Widget widget;

View File

@ -6,9 +6,12 @@ void main() {
group('StringGenerators', () { group('StringGenerators', () {
group('Basic', () { group('Basic', () {
test('assert chart empty', () { test('assert chart empty', () {
expect(() { expect(
StringGenerators.getRandomString(8); () {
}, throwsAssertionError,); StringGenerators.getRandomString(8);
},
throwsAssertionError,
);
}); });
test('only lowercase string', () { test('only lowercase string', () {
@ -27,8 +30,11 @@ void main() {
test('only uppercase string', () { test('only uppercase string', () {
const int length = 8; const int length = 8;
final String generatedString = StringGenerators.getRandomString(length, final String generatedString = StringGenerators.getRandomString(
hasLowercaseLetters: false, hasUppercaseLetters: true,); length,
hasLowercaseLetters: false,
hasUppercaseLetters: true,
);
expect(generatedString, isNot(matches(regExpNewLines))); expect(generatedString, isNot(matches(regExpNewLines)));
expect(generatedString, isNot(matches(regExpWhiteSpaces))); expect(generatedString, isNot(matches(regExpWhiteSpaces)));
@ -41,10 +47,12 @@ void main() {
test('only numbers string', () { test('only numbers string', () {
const int length = 8; const int length = 8;
final String generatedString = StringGenerators.getRandomString(length, final String generatedString = StringGenerators.getRandomString(
hasLowercaseLetters: false, length,
hasUppercaseLetters: false, hasLowercaseLetters: false,
hasNumbers: true,); hasUppercaseLetters: false,
hasNumbers: true,
);
expect(generatedString, isNot(matches(regExpNewLines))); expect(generatedString, isNot(matches(regExpNewLines)));
expect(generatedString, isNot(matches(regExpWhiteSpaces))); expect(generatedString, isNot(matches(regExpWhiteSpaces)));
@ -78,12 +86,14 @@ void main() {
group('Strict mode', () { group('Strict mode', () {
test('All', () { test('All', () {
const int length = 5; const int length = 5;
final String generatedString = StringGenerators.getRandomString(length, final String generatedString = StringGenerators.getRandomString(
hasLowercaseLetters: true, length,
hasUppercaseLetters: true, hasLowercaseLetters: true,
hasNumbers: true, hasUppercaseLetters: true,
hasSymbols: true, hasNumbers: true,
isStrict: true,); hasSymbols: true,
isStrict: true,
);
expect(generatedString, isNot(matches(regExpNewLines))); expect(generatedString, isNot(matches(regExpNewLines)));
expect(generatedString, isNot(matches(regExpWhiteSpaces))); expect(generatedString, isNot(matches(regExpWhiteSpaces)));
@ -95,12 +105,14 @@ void main() {
}); });
test('Lowercase letters and numbers', () { test('Lowercase letters and numbers', () {
const int length = 3; const int length = 3;
final String generatedString = StringGenerators.getRandomString(length, final String generatedString = StringGenerators.getRandomString(
hasLowercaseLetters: true, length,
hasUppercaseLetters: false, hasLowercaseLetters: true,
hasNumbers: true, hasUppercaseLetters: false,
hasSymbols: false, hasNumbers: true,
isStrict: true,); hasSymbols: false,
isStrict: true,
);
expect(generatedString, isNot(matches(regExpNewLines))); expect(generatedString, isNot(matches(regExpNewLines)));
expect(generatedString, isNot(matches(regExpWhiteSpaces))); expect(generatedString, isNot(matches(regExpWhiteSpaces)));