lint work

This commit is contained in:
Christien Rioux 2023-07-26 15:58:38 -04:00
parent 6e8725f569
commit fe9d9f8aca
8 changed files with 129 additions and 117 deletions

View file

@ -1,4 +1,5 @@
import 'package:awesome_extensions/awesome_extensions.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -33,11 +34,11 @@ class NewAccountPageState extends ConsumerState<NewAccountPage> {
final localAccounts = ref.read(localAccountsProvider.notifier);
final logins = ref.read(loginsProvider.notifier);
final profile = proto.Profile();
profile.name = _formKey.currentState!.fields[formFieldName]!.value;
profile.title = _formKey.currentState!.fields[formFieldTitle]!.value;
final account = proto.Account();
account.profile = profile;
final profile = proto.Profile()
..name = _formKey.currentState!.fields[formFieldName]!.value as String
..title =
_formKey.currentState!.fields[formFieldTitle]!.value as String;
final account = proto.Account()..profile = profile;
final localAccount = await localAccounts.newAccount(
identityMaster: imws.identityMaster,
identitySecret: imws.identitySecret,
@ -46,65 +47,67 @@ class NewAccountPageState extends ConsumerState<NewAccountPage> {
// Log in the new account by default with no pin
final ok = await logins
.loginWithNone(localAccount.identityMaster.masterRecordKey);
assert(ok == true);
} catch (e) {
assert(ok == true, 'login with none should never fail');
} on Exception catch (_) {
await imws.delete();
rethrow;
}
}
Widget _newAccountForm(BuildContext context,
{required Future<void> Function(GlobalKey<FormBuilderState>) onSubmit}) => FormBuilder(
key: _formKey,
child: ListView(
children: [
Text(translate('new_account_page.header'))
.textStyle(context.headlineSmall)
.paddingSymmetric(vertical: 16),
FormBuilderTextField(
autofocus: true,
name: formFieldName,
decoration:
InputDecoration(hintText: translate('account.form_name')),
maxLength: 64,
// The validator receives the text that the user has entered.
validator: FormBuilderValidators.compose([
FormBuilderValidators.required(),
]),
),
FormBuilderTextField(
name: formFieldTitle,
maxLength: 64,
decoration:
InputDecoration(hintText: translate('account.form_title')),
),
Row(children: [
const Spacer(),
Text(translate('new_account_page.instructions'))
.toCenter()
.flexible(flex: 6),
const Spacer(),
]).paddingSymmetric(vertical: 4),
ElevatedButton(
onPressed: () async {
if (_formKey.currentState?.saveAndValidate() ?? false) {
setState(() {
isInAsyncCall = true;
});
try {
await onSubmit(_formKey);
} finally {
{required Future<void> Function(GlobalKey<FormBuilderState>)
onSubmit}) =>
FormBuilder(
key: _formKey,
child: ListView(
children: [
Text(translate('new_account_page.header'))
.textStyle(context.headlineSmall)
.paddingSymmetric(vertical: 16),
FormBuilderTextField(
autofocus: true,
name: formFieldName,
decoration:
InputDecoration(hintText: translate('account.form_name')),
maxLength: 64,
// The validator receives the text that the user has entered.
validator: FormBuilderValidators.compose([
FormBuilderValidators.required(),
]),
),
FormBuilderTextField(
name: formFieldTitle,
maxLength: 64,
decoration:
InputDecoration(hintText: translate('account.form_title')),
),
Row(children: [
const Spacer(),
Text(translate('new_account_page.instructions'))
.toCenter()
.flexible(flex: 6),
const Spacer(),
]).paddingSymmetric(vertical: 4),
ElevatedButton(
onPressed: () async {
if (_formKey.currentState?.saveAndValidate() ?? false) {
setState(() {
isInAsyncCall = false;
isInAsyncCall = true;
});
try {
await onSubmit(_formKey);
} finally {
setState(() {
isInAsyncCall = false;
});
}
}
}
},
child: Text(translate('new_account_page.create')),
).paddingSymmetric(vertical: 4).alignAtCenterRight(),
],
),
);
},
child: Text(translate('new_account_page.create')),
).paddingSymmetric(vertical: 4).alignAtCenterRight(),
],
),
);
@override
Widget build(BuildContext context) {
@ -125,7 +128,7 @@ class NewAccountPageState extends ConsumerState<NewAccountPage> {
FocusScope.of(context).unfocus();
try {
await createAccount();
} catch (e) {
} on Exception catch (e) {
await QuickAlert.show(
context: context,
type: QuickAlertType.error,
@ -140,6 +143,7 @@ class NewAccountPageState extends ConsumerState<NewAccountPage> {
).paddingSymmetric(horizontal: 24, vertical: 8),
).withModalHUD(context, displayModalHUD);
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);