TF-528 Apply linter for some widget

This commit is contained in:
dab246
2022-05-04 11:15:37 +07:00
committed by Dat H. Pham
parent dbbc13eab4
commit 4088c88649
35 changed files with 198 additions and 223 deletions
@@ -115,11 +115,6 @@ class EmailController extends BaseController {
}
}
@override
void onData(Either<Failure, Success> newState) {
super.onData(newState);
}
@override
void onDone() {
viewState.value.fold(
@@ -271,7 +266,7 @@ class EmailController extends BaseController {
context: context,
builder: (_) =>
PointerInterceptor(child: (DownloadingFileDialogBuilder()
..key(Key('downloading_file_dialog'))
..key(const Key('downloading_file_dialog'))
..title(AppLocalizations.of(context).preparing_to_export)
..content(AppLocalizations.of(context).downloading_file(attachment.name ?? ''))
..actionText(AppLocalizations.of(context).cancel)
@@ -285,7 +280,7 @@ class EmailController extends BaseController {
context: context,
builder: (_) =>
PointerInterceptor(child: (DownloadingFileDialogBuilder()
..key(Key('downloading_file_for_web_dialog'))
..key(const Key('downloading_file_for_web_dialog'))
..title(AppLocalizations.of(context).preparing_to_save)
..content(AppLocalizations.of(context).downloading_file(attachment.name ?? '')))
.build()));
@@ -301,7 +296,7 @@ class EmailController extends BaseController {
}
void _exportAttachmentFailureAction(Failure failure) {
if (failure is ExportAttachmentFailure && !(failure.exception is CancelDownloadFileException)) {
if (failure is ExportAttachmentFailure && failure.exception is! CancelDownloadFileException) {
popBack();
}
}
@@ -589,12 +584,12 @@ class EmailController extends BaseController {
context: context,
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
builder: (BuildContext context) => PointerInterceptor(child: (ConfirmDialogBuilder(imagePaths)
..key(Key('confirm_dialog_delete_email_permanently'))
..key(const Key('confirm_dialog_delete_email_permanently'))
..title(DeleteActionType.single.getTitleDialog(context))
..content(DeleteActionType.single.getContentDialog(context))
..addIcon(SvgPicture.asset(imagePaths.icRemoveDialog, fit: BoxFit.fill))
..colorConfirmButton(AppColor.colorConfirmActionDialog)
..styleTextConfirmButton(TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorActionDeleteConfirmDialog))
..styleTextConfirmButton(const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: AppColor.colorActionDeleteConfirmDialog))
..onCloseButtonAction(() => popBack())
..onConfirmButtonAction(DeleteActionType.single.getConfirmActionName(context), () => _deleteEmailPermanentlyAction(context, email))
..onCancelButtonAction(AppLocalizations.of(context).cancel, () => popBack()))
@@ -55,16 +55,16 @@ class AttachmentFileTileBuilder {
splashColor: Colors.transparent ,
highlightColor: Colors.transparent),
child: Container(
key: Key('attach_file_tile'),
key: const Key('attach_file_tile'),
alignment: Alignment.center,
margin: EdgeInsets.only(top:heightItem != null ? 8 : 0),
height: heightItem ?? null,
height: heightItem,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: AppColor.attachmentFileBorderColor),
color: Colors.white),
child: MediaQuery(
data: MediaQueryData(padding: EdgeInsets.zero),
data: const MediaQueryData(padding: EdgeInsets.zero),
child: Stack(
alignment: AlignmentDirectional.bottomEnd,
children: [
@@ -85,7 +85,7 @@ class AttachmentFileTileBuilder {
_attachment.name ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: AppColor.attachmentFileNameColor, fontWeight: FontWeight.w500),
style: const TextStyle(fontSize: 12, color: AppColor.attachmentFileNameColor, fontWeight: FontWeight.w500),
)),
subtitle: _attachment.size != null && _attachment.size?.value != 0
? Transform(
@@ -94,7 +94,7 @@ class AttachmentFileTileBuilder {
filesize(_attachment.size?.value),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: AppColor.attachmentFileSizeColor)))
style: const TextStyle(fontSize: 12, color: AppColor.attachmentFileSizeColor)))
: null,
trailing: buttonAction != null
? Transform(
@@ -134,7 +134,7 @@ class AttachmentFileTileBuilder {
Container(color: AppColor.backgroundCountAttachment),
Text(
'+${_attachmentSize - _limitDisplayAttachment + 1}',
style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold))
style: const TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold))
],
),
);
@@ -23,9 +23,9 @@ Decoration _radiusBoxDecoration({
return color;
}).toList()
: [
Color.fromRGBO(0, 0, 0, 0.1),
Color(0x32E5E5E5),
Color.fromRGBO(0, 0, 0, 0.1),
const Color.fromRGBO(0, 0, 0, 0.1),
const Color(0x32E5E5E5),
const Color.fromRGBO(0, 0, 0, 0.1),
],
stops: [animation.value - 2, animation.value, animation.value + 1]));
}
@@ -50,7 +50,7 @@ class _AttachmentsPlaceHolderLoadingState extends State<AttachmentsPlaceHolderLo
@override
void initState() {
super.initState();
_animationController = AnimationController(duration: Duration(seconds: 1), vsync: this)..repeat();
_animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this)..repeat();
_animation = Tween<double>(begin: -2, end: 2)
.animate(CurvedAnimation(curve: Curves.easeInOutSine, parent: _animationController));
}
@@ -67,13 +67,13 @@ class _AttachmentsPlaceHolderLoadingState extends State<AttachmentsPlaceHolderLo
animation: _animation,
builder: (BuildContext context, Widget? child) {
return Container(
margin: EdgeInsets.only(top: 20),
margin: const EdgeInsets.only(top: 20),
padding: EdgeInsets.zero,
color: Colors.transparent,
child: Row(children: [
_placeHolderAttachment(context),
if (widget.responsiveUtils.isDesktop(context))
SizedBox(width: 16),
const SizedBox(width: 16),
if (widget.responsiveUtils.isDesktop(context))
_placeHolderAttachment(context),
]),
@@ -91,7 +91,7 @@ class _AttachmentsPlaceHolderLoadingState extends State<AttachmentsPlaceHolderLo
height: 55,
width: width * percentAttachment,
margin: EdgeInsets.zero,
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16),
decoration: _radiusBoxDecoration(animation: _animation),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -100,14 +100,14 @@ class _AttachmentsPlaceHolderLoadingState extends State<AttachmentsPlaceHolderLo
height: 24,
width: 24,
decoration: _radiusBoxDecoration(animation: _animation, radius: 12)),
SizedBox(width: 8),
const SizedBox(width: 8),
Expanded(child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 5,
decoration: _radiusBoxDecoration(animation: _animation)),
SizedBox(height: 10),
const SizedBox(height: 10),
Container(
height: 5,
decoration: _radiusBoxDecoration(animation: _animation))
@@ -27,12 +27,12 @@ class BottomBarMailWidgetBuilder {
Widget build() {
return Container(
key: Key('bottom_bar_messenger_widget'),
key: const Key('bottom_bar_messenger_widget'),
alignment: Alignment.center,
color: Colors.white,
child: MediaQuery(
data: MediaQueryData(padding: EdgeInsets.zero),
child: _presentationEmail != null ? _buildListOptionButton(_presentationEmail!) : SizedBox.shrink()
data: const MediaQueryData(padding: EdgeInsets.zero),
child: _presentationEmail != null ? _buildListOptionButton(_presentationEmail!) : const SizedBox.shrink()
)
);
}
@@ -44,7 +44,7 @@ class BottomBarMailWidgetBuilder {
children: [
if (presentationEmail.numberOfAllEmailAddress() > 1)
Expanded(child: (ButtonBuilder(_imagePaths.icReplyAll)
..key(Key('button_reply_all_message'))
..key(const Key('button_reply_all_message'))
..size(15)
..paddingIcon(EdgeInsets.only(
top: _responsiveUtils.isMobile(_context) ? 10 : 16,
@@ -60,7 +60,7 @@ class BottomBarMailWidgetBuilder {
..text(AppLocalizations.of(_context).reply_all, isVertical: _responsiveUtils.isMobile(_context)))
.build()),
Expanded(child: (ButtonBuilder(_imagePaths.icReply)
..key(Key('button_reply_message'))
..key(const Key('button_reply_message'))
..size(20)
..paddingIcon(EdgeInsets.only(
top: _responsiveUtils.isMobile(_context) ? 10 : 16,
@@ -76,7 +76,7 @@ class BottomBarMailWidgetBuilder {
..text(AppLocalizations.of(_context).reply, isVertical: _responsiveUtils.isMobile(_context)))
.build()),
Expanded(child: (ButtonBuilder(_imagePaths.icForward)
..key(Key('button_forward_message'))
..key(const Key('button_forward_message'))
..size(20)
..paddingIcon(EdgeInsets.only(
top: _responsiveUtils.isMobile(_context) ? 10 : 16,
@@ -93,7 +93,7 @@ class BottomBarMailWidgetBuilder {
.build()),
if (!_responsiveUtils.isDesktop(_context))
Expanded(child: (ButtonBuilder(_imagePaths.icNewMessage)
..key(Key('button_new_message'))
..key(const Key('button_new_message'))
..size(20)
..paddingIcon(EdgeInsets.only(
top: _responsiveUtils.isMobile(_context) ? 10 : 16,
@@ -34,7 +34,7 @@ class EmailActionCupertinoActionSheetActionBuilder extends CupertinoActionSheetA
key: key,
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Padding(
padding: iconLeftPadding ?? EdgeInsets.only(left: 12, right: 16),
padding: iconLeftPadding ?? const EdgeInsets.only(left: 12, right: 16),
child: actionIcon),
Expanded(child: Text(actionName, textAlign: TextAlign.left, style: actionTextStyle())),
]),
@@ -41,18 +41,18 @@ class EmailAddressBottomSheetBuilder {
}
RoundedRectangleBorder _shape() {
return RoundedRectangleBorder(
return const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0)));
}
BoxDecoration _decoration(BuildContext context) {
return BoxDecoration(
return const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0)));
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0)));
}
void show() {
@@ -70,27 +70,27 @@ class EmailAddressBottomSheetBuilder {
Align(
alignment: Alignment.centerRight,
child: IconButton(
padding: EdgeInsets.only(top: 16, right: 16),
padding: const EdgeInsets.only(top: 16, right: 16),
onPressed: () => _onCloseBottomSheetAction?.call(),
icon: SvgPicture.asset(_imagePaths.icCloseMailbox, width: 24, height: 24, fit: BoxFit.fill))),
(AvatarBuilder()
..text('${_emailAddress.asString().characters.first.toUpperCase()}')
..text(_emailAddress.asString().characters.first.toUpperCase())
..size(64)
..addTextStyle(TextStyle(fontWeight: FontWeight.w600, fontSize: 23, color: Colors.white))
..addTextStyle(const TextStyle(fontWeight: FontWeight.w600, fontSize: 23, color: Colors.white))
..avatarColor(_emailAddress.avatarColors))
.build(),
if (_emailAddress.displayName.isNotEmpty)
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16),
padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
child: Text(
_emailAddress.asString(),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: AppColor.colorNameEmail),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: AppColor.colorNameEmail),
)),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: _emailAddress.displayName.isNotEmpty ? 12 : 16),
child: Text(
_emailAddress.emailAddress,
style: TextStyle(fontSize: 17, fontWeight: FontWeight.normal, color: AppColor.colorMessageConfirmDialog),
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.normal, color: AppColor.colorMessageConfirmDialog),
)),
Material(
borderRadius: BorderRadius.circular(20),
@@ -98,16 +98,16 @@ class EmailAddressBottomSheetBuilder {
child: TextButton(
child: Text(
AppLocalizations.of(_context).copy_email_address,
style: TextStyle(fontSize: 13, color: AppColor.colorTextButton, fontWeight: FontWeight.normal),
style: const TextStyle(fontSize: 13, color: AppColor.colorTextButton, fontWeight: FontWeight.normal),
),
onPressed: () => _onCopyEmailAddressAction?.call(_emailAddress)
)
),
SizedBox(height: _emailAddress.displayName.isNotEmpty ? 100 : 130),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 20),
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 20),
child: SizedBox(
key: Key('compose_email_button'),
key: const Key('compose_email_button'),
width: double.infinity,
height: 48,
child: ElevatedButton(
@@ -116,8 +116,8 @@ class EmailAddressBottomSheetBuilder {
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.colorTextButton),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(width: 0, color: AppColor.colorTextButton)))),
child: Text(AppLocalizations.of(_context).compose_email, style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w500)),
side: const BorderSide(width: 0, color: AppColor.colorTextButton)))),
child: Text(AppLocalizations.of(_context).compose_email, style: const TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w500)),
onPressed: () => _onComposeEmailAction?.call(_emailAddress)),
)
)
@@ -40,13 +40,13 @@ class EmailAddressDialogBuilder {
Widget build() {
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
insetPadding: EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(16))),
insetPadding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 16.0),
child: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
width: 400,
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(16))),
child: Wrap(
@@ -54,48 +54,48 @@ class EmailAddressDialogBuilder {
Align(
alignment: Alignment.centerRight,
child: IconButton(
padding: EdgeInsets.only(top: 16, right: 16),
padding: const EdgeInsets.only(top: 16, right: 16),
onPressed: () => _onCloseDialogAction?.call(),
icon: SvgPicture.asset(_imagePaths.icCloseMailbox, width: 24, height: 24, fit: BoxFit.fill))),
Padding(padding: EdgeInsets.symmetric(horizontal: 16),
Padding(padding: const EdgeInsets.symmetric(horizontal: 16),
child: Center(child: (AvatarBuilder()
..text('${_emailAddress.asString().characters.first.toUpperCase()}')
..text(_emailAddress.asString().characters.first.toUpperCase())
..size(64)
..addTextStyle(TextStyle(fontWeight: FontWeight.w600, fontSize: 23, color: Colors.white))
..addTextStyle(const TextStyle(fontWeight: FontWeight.w600, fontSize: 23, color: Colors.white))
..avatarColor(_emailAddress.avatarColors))
.build())),
if (_emailAddress.displayName.isNotEmpty)
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 16),
padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
child: Center(child: Text(
_emailAddress.asString(),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: AppColor.colorNameEmail),
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: AppColor.colorNameEmail),
))
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: _emailAddress.displayName.isNotEmpty ? 12 : 16),
child: Center(child: Text(
_emailAddress.emailAddress,
style: TextStyle(fontSize: 17, fontWeight: FontWeight.normal, color: AppColor.colorMessageConfirmDialog),
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.normal, color: AppColor.colorMessageConfirmDialog),
))
),
Padding(padding: EdgeInsets.symmetric(horizontal: 16),
Padding(padding: const EdgeInsets.symmetric(horizontal: 16),
child: Center(child: Material(
borderRadius: BorderRadius.circular(20),
color: Colors.transparent,
child: TextButton(
child: Text(
AppLocalizations.of(_context).copy_email_address,
style: TextStyle(fontSize: 13, color: AppColor.colorTextButton, fontWeight: FontWeight.normal),
style: const TextStyle(fontSize: 13, color: AppColor.colorTextButton, fontWeight: FontWeight.normal),
),
onPressed: () => _onCopyEmailAddressAction?.call(_emailAddress)
)
))),
SizedBox(height: _emailAddress.displayName.isNotEmpty ? 100 : 130),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 20),
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 20),
child: SizedBox(
key: Key('compose_email_button'),
key: const Key('compose_email_button'),
width: double.infinity,
height: 48,
child: ElevatedButton(
@@ -104,8 +104,8 @@ class EmailAddressDialogBuilder {
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.colorTextButton),
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(width: 0, color: AppColor.colorTextButton)))),
child: Text(AppLocalizations.of(_context).compose_email, style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w500)),
side: const BorderSide(width: 0, color: AppColor.colorTextButton)))),
child: Text(AppLocalizations.of(_context).compose_email, style: const TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.w500)),
onPressed: () => _onComposeEmailAction?.call(_emailAddress)),
)
)
@@ -23,9 +23,9 @@ Decoration _radiusBoxDecoration({
return color;
}).toList()
: [
Color.fromRGBO(0, 0, 0, 0.1),
Color(0x32E5E5E5),
Color.fromRGBO(0, 0, 0, 0.1),
const Color.fromRGBO(0, 0, 0, 0.1),
const Color(0x32E5E5E5),
const Color.fromRGBO(0, 0, 0, 0.1),
],
stops: [animation.value - 2, animation.value, animation.value + 1]));
}
@@ -50,7 +50,7 @@ class _EmailContentPlaceHolderLoadingState extends State<EmailContentPlaceHolder
@override
void initState() {
super.initState();
_animationController = AnimationController(duration: Duration(seconds: 1), vsync: this)..repeat();
_animationController = AnimationController(duration: const Duration(seconds: 1), vsync: this)..repeat();
_animation = Tween<double>(begin: -2, end: 2)
.animate(CurvedAnimation(curve: Curves.easeInOutSine, parent: _animationController));
}
@@ -67,22 +67,22 @@ class _EmailContentPlaceHolderLoadingState extends State<EmailContentPlaceHolder
animation: _animation,
builder: (BuildContext context, Widget? child) {
return Container(
margin: EdgeInsets.only(top: 16),
margin: const EdgeInsets.only(top: 16),
padding: EdgeInsets.zero,
color: Colors.transparent,
child: Column(
children: [
Container(
margin: EdgeInsets.only(right: 64),
margin: const EdgeInsets.only(right: 64),
height: 10,
decoration: _radiusBoxDecoration(animation: _animation, radius: 5)),
SizedBox(height: 16),
const SizedBox(height: 16),
Container(
height: 10,
decoration: _radiusBoxDecoration(animation: _animation, radius: 5)),
SizedBox(height: 16),
const SizedBox(height: 16),
Container(
margin: EdgeInsets.only(right: 128),
margin: const EdgeInsets.only(right: 128),
height: 10,
decoration: _radiusBoxDecoration(animation: _animation, radius: 5)),
],