TF-1098 Apply lints for all module

This commit is contained in:
dab246
2022-10-21 13:31:33 +07:00
committed by Dat H. Pham
parent c6e73d4272
commit ae89802845
58 changed files with 442 additions and 348 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter_lints: 1.0.4
build_runner: 2.1.11
+29
View File
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
-6
View File
@@ -104,12 +104,6 @@ export 'presentation/state/success.dart';
export 'presentation/state/failure.dart';
export 'presentation/state/app_state.dart';
// Local
export 'data/local/config/database_config.dart';
export 'data/local/config/email_address_table.dart';
export 'data/local/database_client.dart';
export 'data/local/database_manager.dart';
// Model
export 'data/model/source_type/data_source_type.dart';
export 'data/model/query/query_parameter.dart';
@@ -2,10 +2,10 @@ import 'package:dio/dio.dart';
extension OptionsExtension on Options {
Options appendHeaders(Map<String, dynamic> additionalHeaders) {
if (this.headers != null) {
this.headers?.addAll(additionalHeaders);
if (headers != null) {
headers?.addAll(additionalHeaders);
} else {
this.headers = additionalHeaders;
headers = additionalHeaders;
}
return this;
}
@@ -75,7 +75,7 @@ class DownloadManager {
await streamController.close();
return streamController.stream.first;
} else {
throw exception;
rethrow;
}
}
return streamController.stream.first;
@@ -100,7 +100,7 @@ class DownloadManager {
html.Url.revokeObjectUrl(url);
} catch (exception) {
log('DownloadManager::createAnchorElementDownloadFileWeb(): ERROR: $exception');
throw exception;
rethrow;
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ class CompressFileUtils {
static const int MAX_IMAGE_WIDTH = 1000;
bool _exceedMaximumImageSize(Uint8List bytesData) {
final maximumSizeBytes = MAXIMUM_IMAGE_SIZE_KB * 1024;
const maximumSizeBytes = MAXIMUM_IMAGE_SIZE_KB * 1024;
final sizeBytesData = bytesData.length;
log('CompressFileUtils::exceedMaximumImageSize(): maximumSizeBytes: $maximumSizeBytes');
log('CompressFileUtils::exceedMaximumImageSize(): sizeBytesData: $sizeBytesData');
@@ -2,23 +2,23 @@
import 'package:equatable/equatable.dart';
abstract class RemoteException extends Equatable implements Exception {
static final connectError = 'Connect error';
static const connectError = 'Connect error';
final String? message;
final int? code;
RemoteException({this.code, this.message});
const RemoteException({this.code, this.message});
}
class UnknownError extends RemoteException {
UnknownError({int? code, String? message}) : super(code: code, message: message);
const UnknownError({int? code, String? message}) : super(code: code, message: message);
@override
List<Object> get props => [];
}
class ConnectError extends RemoteException {
ConnectError() : super(message: RemoteException.connectError);
const ConnectError() : super(message: RemoteException.connectError);
@override
List<Object> get props => [];
@@ -3,17 +3,17 @@ extension DateTimeExtension on DateTime {
bool isToday() {
final now = DateTime.now();
return now.day == this.day && now.month == this.month && now.year == this.year;
return now.day == day && now.month == month && now.year == year;
}
bool isYesterday() {
final yesterday = DateTime.now().subtract(Duration(days: 1));
return yesterday.day == this.day && yesterday.month == this.month && yesterday.year == this.year;
final yesterday = DateTime.now().subtract(const Duration(days: 1));
return yesterday.day == day && yesterday.month == month && yesterday.year == year;
}
bool isThisYear() {
final now = DateTime.now();
return now.year == this.year;
return now.year == year;
}
int daysBetween(DateTime from) {
@@ -1,6 +1,6 @@
extension CapitalizeExtension on String {
String get inCaps => this.length > 0 ?'${this[0].toUpperCase()}${this.toLowerCase().substring(1)}':'';
String get allInCaps => this.toUpperCase();
String get capitalizeFirstEach => this.replaceAll(RegExp(' +'), ' ').split(" ").map((str) => str.inCaps).join(" ");
String get inCaps => length > 0 ?'${this[0].toUpperCase()}${toLowerCase().substring(1)}':'';
String get allInCaps => toUpperCase();
String get capitalizeFirstEach => replaceAll(RegExp(' +'), ' ').split(" ").map((str) => str.inCaps).join(" ");
}
@@ -22,7 +22,7 @@ extension HtmlExtension on String {
String addBlockQuoteTag() => addBlockTag(
'blockquote',
attribute: 'style=\"margin-left:8px;margin-right:8px;padding-left:12px;padding-right:12px;border-left:5px solid #eee;\"');
attribute: 'style="margin-left:8px;margin-right:8px;padding-left:12px;padding-right:12px;border-left:5px solid #eee;"');
String asSignatureHtml() => '--<br><br>$this';
@@ -2,7 +2,7 @@ import 'package:built_collection/built_collection.dart';
import 'package:dartz/dartz.dart';
extension ListExtensions<T> on List<T> {
Tuple2<List<T>, List<T>> split(bool test(T element)) {
Tuple2<List<T>, List<T>> split(bool Function(T element) test) {
final validBuilder = ListBuilder<T>();
final invalidBuilder = ListBuilder<T>();
forEach((element) {
@@ -1,8 +1,8 @@
import 'package:flutter/foundation.dart';
extension URLExtension on String {
static final String prefixUrlHttps = 'https://';
static final String prefixUrlHttp = 'http://';
static const String prefixUrlHttps = 'https://';
static const String prefixUrlHttp = 'http://';
String formatURLValid() {
if (isNotEmpty) {
+5 -5
View File
@@ -53,7 +53,7 @@ class AppToast {
Color? textActionColor,
}
) {
var trailingAction;
Widget? trailingAction;
if (actionName != null) {
if (actionIcon == null) {
@@ -80,7 +80,7 @@ class AppToast {
},
customBorder: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)),
child: Padding(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 8),
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -156,7 +156,7 @@ class AppToast {
shadowColor: Colors.black54,
borderRadius: BorderRadius.all(Radius.circular(radius ?? 10)),
child: Container(
padding: padding ?? EdgeInsets.symmetric(horizontal: 12.0, vertical: 14),
padding: padding ?? const EdgeInsets.symmetric(horizontal: 12.0, vertical: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radius ?? 10.0),
color: bgColor ?? Colors.white,
@@ -172,7 +172,7 @@ class AppToast {
fit: BoxFit.fill,
color: iconColor),
if (icon != null)
SizedBox(width: 10.0),
const SizedBox(width: 10.0),
Expanded(child: Text(
message ?? '',
style: textStyle ?? TextStyle(fontSize: 15, color: textColor ?? Colors.black))),
@@ -184,7 +184,7 @@ class AppToast {
fToast.showToast(
child: toast,
gravity: ToastGravity.BOTTOM,
toastDuration: toastLength ?? Duration(seconds: 3),
toastDuration: toastLength ?? const Duration(seconds: 3),
);
}
}
@@ -1,7 +1,7 @@
final nameClassToolTip = 'tmail-tooltip';
const nameClassToolTip = 'tmail-tooltip';
final tooltipLinkCss = '''
const tooltipLinkCss = '''
.$nameClassToolTip .tooltiptext {
visibility: hidden;
max-width: 400px;
@@ -54,13 +54,13 @@ String generateHtml(String content, {
${javaScripts ?? ''}
</head>
<body>
<div class="tmail-content">${content}</div>
<div class="tmail-content">$content</div>
</body>
</html>
''';
}
final bodyCssStyleForEditor = '''
const bodyCssStyleForEditor = '''
<style>
blockquote {
margin-left: 8px;
@@ -43,9 +43,9 @@ class MessageContentTransformer {
String _transformMessage(String message) {
if (configuration.textTransformers.isNotEmpty) {
configuration.textTransformers.forEach((transformer) {
for (var transformer in configuration.textTransformers) {
message = transformer.process(message);
});
}
}
return message;
}
+1 -1
View File
@@ -2,5 +2,5 @@
import 'package:core/utils/build_utils.dart';
class IconUtils {
static final double defaultIconSize = BuildUtils.isWeb ? 20.0 : 24.0;
static const double defaultIconSize = BuildUtils.isWeb ? 20.0 : 24.0;
}
+3 -3
View File
@@ -2,16 +2,16 @@ import 'package:core/core.dart';
import 'package:flutter/material.dart';
class CommonTextStyle {
static final textStyleNormal = TextStyle(
static const textStyleNormal = TextStyle(
color: AppColor.primaryColor,
fontSize: 14,
fontStyle: FontStyle.normal,
fontWeight: FontWeight.normal,
);
static final defaultTextOverFlow = BuildUtils.isWeb
static const defaultTextOverFlow = BuildUtils.isWeb
? TextOverflow.fade
: TextOverflow.ellipsis;
static final defaultSoftWrap = BuildUtils.isWeb ? false : true;
static const defaultSoftWrap = BuildUtils.isWeb ? false : true;
}
+4 -4
View File
@@ -16,12 +16,12 @@ ThemeData appTheme() {
InputDecorationTheme inputDecorationTheme() {
OutlineInputBorder outlineInputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(28),
borderSide: BorderSide(color: AppColor.baseTextColor),
borderSide: const BorderSide(color: AppColor.baseTextColor),
gapPadding: 10,
);
return InputDecorationTheme(
floatingLabelBehavior: FloatingLabelBehavior.always,
contentPadding: EdgeInsets.symmetric(horizontal: 42, vertical: 20),
contentPadding: const EdgeInsets.symmetric(horizontal: 42, vertical: 20),
enabledBorder: outlineInputBorder,
focusedBorder: outlineInputBorder,
border: outlineInputBorder,
@@ -29,14 +29,14 @@ InputDecorationTheme inputDecorationTheme() {
}
TextTheme textTheme() {
return TextTheme(
return const TextTheme(
bodyText1: TextStyle(color: AppColor.baseTextColor),
bodyText2: TextStyle(color: AppColor.baseTextColor),
);
}
AppBarTheme appBarTheme() {
return AppBarTheme(
return const AppBarTheme(
color: Colors.white,
elevation: 0,
systemOverlayStyle: SystemUiOverlayStyle.light,
@@ -26,21 +26,21 @@ class BackgroundWidgetBuilder {
Widget build() {
return Center(
key: _key ?? Key('BackgroundWidgetBuilder'),
key: _key ?? const Key('BackgroundWidgetBuilder'),
child: CustomScrollView(
slivers: [
SliverFillRemaining(
child: Container(
child: SizedBox(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_image ?? SizedBox.shrink(),
_image ?? const SizedBox.shrink(),
Padding(
padding: EdgeInsets.only(top: _image != null ? 16 : 0),
child: Text(
_text ?? '',
style: TextStyle(color: AppColor.baseTextColor, fontSize: 16),
style: const TextStyle(color: AppColor.baseTextColor, fontSize: 16),
textAlign: TextAlign.center,
),
),
@@ -55,7 +55,7 @@ class ConfirmationDialogActionSheetBuilder {
builder: (context) => PointerInterceptor(child: CupertinoActionSheet(
actions: [
Container(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 10),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
color: Colors.white,
child: MouseRegion(
cursor: BuildUtils.isWeb ? MaterialStateMouseCursor.clickable : MouseCursor.defer,
@@ -63,7 +63,7 @@ class ConfirmationDialogActionSheetBuilder {
child: Text(
_messageText ?? '',
textAlign: TextAlign.center,
style: _styleMessage ?? TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog)),
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog)),
onPressed: () => {},
),
)
@@ -75,7 +75,7 @@ class ConfirmationDialogActionSheetBuilder {
child: CupertinoActionSheetAction(
child: Text(
_confirmText ?? '',
style: _styleConfirmButton ?? TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionDeleteConfirmDialog)),
style: _styleConfirmButton ?? const TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionDeleteConfirmDialog)),
onPressed: () => _onConfirmActionClick?.call(),
),
)
@@ -86,7 +86,7 @@ class ConfirmationDialogActionSheetBuilder {
child: CupertinoActionSheetAction(
child: Text(
_cancelText ?? '',
style: _styleCancelButton ?? TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionCancelDialog)),
style: _styleCancelButton ?? const TextStyle(fontWeight: FontWeight.w500, fontSize: 20, color: AppColor.colorActionCancelDialog)),
onPressed: () => _onCancelActionClick?.call(),
),
),
@@ -26,7 +26,7 @@ abstract class CupertinoActionSheetActionBuilder<T> {
}
TextStyle actionTextStyle({TextStyle? textStyle}) {
return textStyle ?? TextStyle(fontSize: 17, color: AppColor.colorNameEmail);
return textStyle ?? const TextStyle(fontSize: 17, color: AppColor.colorNameEmail);
}
Widget build();
@@ -22,7 +22,7 @@ abstract class CupertinoActionSheetNoIconBuilder<T> {
}
TextStyle actionTextStyle({TextStyle? textStyle}) {
return textStyle ?? TextStyle(fontSize: 17, color: Colors.black);
return textStyle ?? const TextStyle(fontSize: 17, color: Colors.black);
}
Widget build();
@@ -12,7 +12,7 @@ class FullScreenActionSheetBuilder {
final Widget? titleWidget;
final Widget? cancelWidget;
OnCloseActionClick? onCloseActionClick;
late double _statusBarHeight = MediaQuery.of(context).padding.top;
late double _statusBarHeight;
FullScreenActionSheetBuilder({
required this.context,
@@ -20,7 +20,9 @@ class FullScreenActionSheetBuilder {
this.titleWidget,
this.cancelWidget,
this.onCloseActionClick,
});
}) {
_statusBarHeight = MediaQuery.of(context).padding.top;
}
Future show() {
return showModalBottomSheet(
@@ -44,13 +46,13 @@ class FullScreenActionSheetBuilder {
child: Padding(
padding: EdgeInsets.only(top: _statusBarHeight),
child: ClipRRect(
borderRadius: BorderRadius.only(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(14),
topLeft: Radius.circular(14),
),
child: Scaffold(
appBar: AppBar(
leading: SizedBox.shrink(),
leading: const SizedBox.shrink(),
title: titleWidget,
centerTitle: true,
actions: [
@@ -11,7 +11,7 @@ class ButtonBuilder {
OnPressActionWithPositionClick? _onPressActionWithPositionClick;
BuildContext? _context;
String? _icon;
final String? _icon;
String? _text;
double? _size;
EdgeInsets? _paddingIcon;
@@ -93,7 +93,7 @@ class ButtonBuilder {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: () => _onPressActionClick != null ? _onPressActionClick?.call() : null,
onTap: () => _onPressActionClick != null ? _onPressActionClick!.call() : null,
onTapDown: (detail) {
if (_onPressActionWithPositionClick != null && _context != null) {
final screenSize = MediaQuery.of(_context!).size;
@@ -147,7 +147,7 @@ class ButtonBuilder {
}
Widget _buildIcon() => Padding(
padding: _paddingIcon ?? EdgeInsets.all(10),
padding: _paddingIcon ?? const EdgeInsets.all(10),
child: SvgPicture.asset(
_icon ?? '',
width: _size ?? 24,
@@ -157,11 +157,11 @@ class ButtonBuilder {
Widget _buildText() {
return Text(
'${_text ?? ''}',
_text ?? '',
maxLines: 1,
softWrap: CommonTextStyle.defaultSoftWrap,
overflow: CommonTextStyle.defaultTextOverFlow,
style: _textStyle ?? TextStyle(
style: _textStyle ?? const TextStyle(
fontSize: 12,
color: AppColor.colorTextButton),
);
@@ -19,13 +19,13 @@ Widget buildIconWeb({
}) {
return Material(
color: colorSelected ?? Colors.transparent,
shape: shapeBorder ?? CircleBorder(),
shape: shapeBorder ?? const CircleBorder(),
child: IconButton(
icon: icon,
focusColor: colorFocus,
iconSize: iconSize,
constraints: minSize != null ? BoxConstraints(minWidth: minSize, minHeight: minSize) : null,
padding: iconPadding ?? EdgeInsets.all(8.0),
padding: iconPadding ?? const EdgeInsets.all(8.0),
splashRadius: splashRadius ?? 15,
tooltip: tooltip ?? '',
onPressed: onTap)
@@ -40,7 +40,7 @@ Widget buildIconWebHasPosition(BuildContext context, {
}) {
return Material(
color: Colors.transparent,
shape: CircleBorder(),
shape: const CircleBorder(),
child: InkWell(
onTapDown: (detail) {
final screenSize = MediaQuery.of(context).size;
@@ -54,7 +54,7 @@ Widget buildIconWebHasPosition(BuildContext context, {
onTapDown?.call(position);
},
onTap: () => onTap?.call(),
borderRadius: BorderRadius.all(Radius.circular(12)),
borderRadius: const BorderRadius.all(const Radius.circular(12)),
child: Tooltip(
message: tooltip ?? '',
child: icon,
@@ -68,15 +68,15 @@ Widget buildTextCircleButton(String text, {
IconWebCallback? onTap,
}) {
return Material(
shape: CircleBorder(),
shape: const CircleBorder(),
color: Colors.transparent,
child: TextButton(
child: Text(
text,
style: textStyle ?? TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor)),
style: textStyle ?? const TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor)),
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.colorFocusButton),
shape: MaterialStateProperty.all(CircleBorder()),
shape: MaterialStateProperty.all(const CircleBorder()),
padding: MaterialStateProperty.resolveWith<EdgeInsets>((Set<MaterialState> states) => EdgeInsets.zero),
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
onPressed: () => onTap?.call()
@@ -90,12 +90,12 @@ Widget buildTextIcon(String text, {
IconWebCallback? onTap,
}) {
return Material(
shape: CircleBorder(),
shape: const CircleBorder(),
color: Colors.transparent,
child: InkWell(
child: Padding(
padding: padding ?? EdgeInsets.all(10),
child: Text(text, style: textStyle ?? TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor))),
padding: padding ?? const EdgeInsets.all(10),
child: Text(text, style: textStyle ?? const TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor))),
onTap: () => onTap?.call()
)
);
@@ -120,12 +120,12 @@ Widget buildTextButton(String text, {
backgroundColor: MaterialStateProperty.resolveWith((states) => backgroundColor ?? AppColor.colorTextButton),
elevation: MaterialStateProperty.resolveWith((states) => 0),
padding: MaterialStateProperty.resolveWith<EdgeInsets>(
(Set<MaterialState> states) => padding ?? EdgeInsets.symmetric(horizontal: 8)),
(Set<MaterialState> states) => padding ?? const EdgeInsets.symmetric(horizontal: 8)),
shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius ?? 0)))),
child: Text(
text,
textAlign: TextAlign.center,
style: textStyle ?? TextStyle(
style: textStyle ?? const TextStyle(
fontSize: 17,
color: Colors.white,
fontWeight: FontWeight.w500)),
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class LabeledCheckbox extends StatelessWidget {
const LabeledCheckbox({
const LabeledCheckbox({Key? key,
required this.label,
this.contentPadding,
this.value,
@@ -11,7 +11,7 @@ class LabeledCheckbox extends StatelessWidget {
this.gap = 4.0,
this.bold = false,
this.focusNode,
});
}) : super(key: key);
final String label;
final EdgeInsets? contentPadding;
@@ -21,7 +21,7 @@ abstract class ContextMenuActionBuilder<T> {
}
TextStyle actionTextStyle() {
return TextStyle(
return const TextStyle(
fontSize: 15,
color: AppColor.nameUserColor);
}
@@ -39,18 +39,18 @@ class ContextMenuBuilder {
}
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 build() {
@@ -68,22 +68,22 @@ class ContextMenuBuilder {
onTap: () => {},
child: Wrap(
children: [
_header ?? SizedBox.shrink(),
Divider(),
_header ?? const SizedBox.shrink(),
const Divider(),
areTilesHorizontal
? Row(children: [
..._actionTiles,
_actionTiles.isNotEmpty && _footer != null ? Divider() : SizedBox.shrink()
_actionTiles.isNotEmpty && _footer != null ? const Divider() : const SizedBox.shrink()
])
: Column(children: [
..._actionTiles,
_actionTiles.isNotEmpty && _footer != null ? Divider() : SizedBox.shrink()
_actionTiles.isNotEmpty && _footer != null ? const Divider() : const SizedBox.shrink()
]),
_footer != null
? Padding(
padding: EdgeInsets.only(bottom: 10.0),
child: Wrap(children: [_footer ?? SizedBox.shrink()]))
: SizedBox.shrink(),
padding: const EdgeInsets.only(bottom: 10.0),
child: Wrap(children: [_footer ?? const SizedBox.shrink()]))
: const SizedBox.shrink(),
],
),
),
@@ -24,7 +24,7 @@ class ContextMenuHeaderBuilder {
transform: Matrix4.translationValues(12, 5, 0.0),
child: Text(
_label ?? '',
style: _textStyle ?? TextStyle(fontSize: 20.0, color: AppColor.nameUserColor, fontWeight: FontWeight.w500),
style: _textStyle ?? const TextStyle(fontSize: 20.0, color: AppColor.nameUserColor, fontWeight: FontWeight.w500),
),
));
}
@@ -15,7 +15,7 @@ class SimpleContextMenuActionBuilder extends ContextMenuActionBuilder<void> {
return ListTile(
key: key,
leading: Padding(
padding: EdgeInsets.only(left: 12),
padding: const EdgeInsets.only(left: 12),
child: actionIcon),
title: Text(actionName, style: actionTextStyle()),
onTap: () {
@@ -128,9 +128,9 @@ class ConfirmDialogBuilder {
} else {
return Dialog(
key: _key,
shape: RoundedRectangleBorder(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(16))),
insetPadding: EdgeInsets.symmetric(
insetPadding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0),
child: _bodyContent(),
@@ -141,49 +141,49 @@ class ConfirmDialogBuilder {
Widget _bodyContent() {
return Container(
width: _widthDialog ?? 400,
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(16))),
borderRadius: const BorderRadius.all(Radius.circular(16))),
margin: _margin,
child: Wrap(children: [
if (_onCloseButtonAction != null)
Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.only(top: 8, right: 8),
padding: const EdgeInsets.only(top: 8, right: 8),
child: buildIconWeb(
icon: SvgPicture.asset(_imagePath.icCloseMailbox, fit: BoxFit.fill),
onTap: () => _onCloseButtonAction?.call())
)),
if (_iconWidget != null)
Container(
margin: _marginIcon ?? EdgeInsets.only(top: 24),
margin: _marginIcon ?? const EdgeInsets.only(top: 24),
alignment: Alignment.center,
child: _iconWidget,
),
if (_title.isNotEmpty)
Padding(
padding: _paddingTitle ?? EdgeInsets.only(top: 12),
padding: _paddingTitle ?? const EdgeInsets.only(top: 12),
child: Center(
child: Text(
_title,
textAlign: TextAlign.center,
style: _styleTitle ?? TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500)
style: _styleTitle ?? const TextStyle(fontSize: 20.0, color: AppColor.colorActionDeleteConfirmDialog, fontWeight: FontWeight.w500)
)
)
),
if (_content.isNotEmpty)
Padding(
padding: _paddingContent ?? EdgeInsets.symmetric(horizontal: 16, vertical: 24),
padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
child: Center(
child: Text(_content,
textAlign: TextAlign.center,
style: _styleContent ?? TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
),
),
),
Padding(
padding: _paddingButton ?? EdgeInsets.only(bottom: 16, left: 16, right: 16),
padding: _paddingButton ?? const EdgeInsets.only(bottom: 16, left: 16, right: 16),
child: Row(
children: [
if (_cancelText.isNotEmpty)
@@ -193,7 +193,7 @@ class ConfirmDialogBuilder {
radius: _radiusButton,
textStyle: _styleTextCancelButton,
action: _onCancelButtonAction)),
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) SizedBox(width: 16),
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) const SizedBox(width: 16),
if (_confirmText.isNotEmpty)
Expanded(child: _buildButton(
name: _confirmText,
@@ -225,11 +225,11 @@ class ConfirmDialogBuilder {
side: BorderSide(width: 0, color: bgColor ?? AppColor.colorTextButton),
)),
padding: MaterialStateProperty.resolveWith<EdgeInsets>(
(Set<MaterialState> states) => EdgeInsets.symmetric(horizontal: 16)),
(Set<MaterialState> states) => const EdgeInsets.symmetric(horizontal: 16)),
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
child: Text(name ?? '',
textAlign: TextAlign.center,
style: textStyle ?? TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white)),
style: textStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white)),
)
);
}
@@ -37,21 +37,21 @@ class DownloadingFileDialogBuilder {
Widget build() {
return CupertinoAlertDialog(
key: _key ?? Key('DownloadingFileBuilder'),
title: Text(_title, style: TextStyle(fontSize: 17.0, color: Colors.black)),
key: _key ?? const Key('DownloadingFileBuilder'),
title: Text(_title, style: const TextStyle(fontSize: 17.0, color: Colors.black)),
content: Padding(
padding: EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0),
child: Center(
child: Column(
children: [
SizedBox(
const SizedBox(
width: 20.0,
height: 20.0,
child: CupertinoActivityIndicator()),
SizedBox(height: 16),
const SizedBox(height: 16),
Text(
_content,
style: TextStyle(fontSize: 13.0, color: Colors.black),
style: const TextStyle(fontSize: 13.0, color: Colors.black),
softWrap: false,
maxLines: 1)
],
@@ -60,10 +60,10 @@ class DownloadingFileDialogBuilder {
actions: [
if (_actionText.isNotEmpty)
Padding(
padding: EdgeInsets.only(bottom: kIsWeb ? 16 : 0, top: kIsWeb ? 16 : 0),
padding: const EdgeInsets.only(bottom: kIsWeb ? 16 : 0, top: kIsWeb ? 16 : 0),
child: TextButton(
onPressed: () => _onCancelDownloadActionClick?.call(),
child: Text(_actionText, style: TextStyle(fontSize: 17.0, color: AppColor.appColor)),
child: Text(_actionText, style: const TextStyle(fontSize: 17.0, color: AppColor.appColor)),
))
],
);
@@ -82,26 +82,26 @@ class EditTextDialogBuilder {
Widget build() {
return Dialog(
key: _key,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
insetPadding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
insetPadding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
child: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
width: 400,
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20))),
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return Container(
padding: EdgeInsets.only(left: 30, right: 30, top: 30, bottom: 24),
padding: const EdgeInsets.only(left: 30, right: 30, top: 30, bottom: 24),
child: Wrap(
children: <Widget>[
Text(
_title,
style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
style: const TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
textAlign: TextAlign.center),
Padding(
padding: EdgeInsets.only(top: 20),
padding: const EdgeInsets.only(top: 20),
child: TextFormField(
keyboardType: TextInputType.visiblePassword,
onChanged: (value) => _onTextChanged(value, setState),
@@ -109,12 +109,12 @@ class EditTextDialogBuilder {
controller: _textController,
decoration: InputDecoration(
errorText: _error,
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
enabledBorder: const UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
hintText: _hintText),
)
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16, top: 24),
padding: const EdgeInsets.only(left: 16, right: 16, top: 24),
child: Row(
children: [
Expanded(
@@ -123,7 +123,7 @@ class EditTextDialogBuilder {
bgColor: AppColor.colorContentEmail,
action: () => _onCancelButtonPress(context))
),
SizedBox(width: 20),
const SizedBox(width: 20),
Expanded(
child: _buildButton(
name: _confirmText,
@@ -164,7 +164,7 @@ class EditTextDialogBuilder {
side: BorderSide(width: 0, color: bgColor ?? AppColor.colorTextButton),
)),
padding: MaterialStateProperty.resolveWith<EdgeInsets>(
(Set<MaterialState> states) => EdgeInsets.symmetric(horizontal: 16)),
(Set<MaterialState> states) => const EdgeInsets.symmetric(horizontal: 16)),
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
child: Text(name ?? '',
textAlign: TextAlign.center,
@@ -40,7 +40,7 @@ class ScrollingFloatingButtonAnimated extends StatefulWidget {
/// Value to indicate if animate or not the icon
final bool? animateIcon;
ScrollingFloatingButtonAnimated(
const ScrollingFloatingButtonAnimated(
{Key? key,
required this.icon,
required this.text,
@@ -72,10 +72,10 @@ class _ScrollingFloatingButtonAnimatedState
@override
void initState() {
_animationController = new AnimationController(
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 250),
reverseDuration: Duration(milliseconds: 250),
duration: const Duration(milliseconds: 250),
reverseDuration: const Duration(milliseconds: 250),
animationBehavior: AnimationBehavior.normal,
lowerBound: 0,
upperBound: 120,
@@ -95,7 +95,6 @@ class _ScrollingFloatingButtonAnimatedState
void _handleScroll() {
ScrollController _scrollController = widget.scrollController!;
_scrollController.addListener(() {
print(_scrollController.position.userScrollDirection);
if (_scrollController.position.pixels > widget.limitIndicator! &&
_scrollController.position.userScrollDirection ==
ScrollDirection.reverse) {
@@ -122,7 +121,7 @@ class _ScrollingFloatingButtonAnimatedState
Widget build(BuildContext context) {
final shortestSide = MediaQuery.of(context).size.shortestSide;
if (shortestSide < 60) {
return SizedBox.shrink();
return const SizedBox.shrink();
}
return Card(
elevation: widget.elevation,
@@ -121,7 +121,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
</script>
''';
final scriptsDisableZoom = '''
const scriptsDisableZoom = '''
<script type="text/javascript">
document.addEventListener('wheel', function(e) {
e.ctrlKey && e.preventDefault();
@@ -165,7 +165,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
final dataGetHeight = <String, Object>{'type': 'toIframe: getHeight', 'view' : createdViewId};
final dataGetWidth = <String, Object>{'type': 'toIframe: getWidth', 'view' : createdViewId};
final jsonEncoder = JsonEncoder();
const jsonEncoder = JsonEncoder();
final jsonGetHeight = jsonEncoder.convert(dataGetHeight);
final jsonGetWidth = jsonEncoder.convert(dataGetWidth);
@@ -220,7 +220,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
if (urlString.startsWith('mailto:')) {
widget.mailtoDelegate?.call(Uri.parse(urlString));
} else {
html.window.open('$urlString', '_blank');
html.window.open(urlString, '_blank');
}
}
}
@@ -251,7 +251,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
}
Widget _buildLoadingView() {
return Padding(
return const Padding(
padding: EdgeInsets.all(16),
child: SizedBox(
width: 30,
@@ -81,7 +81,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
}
Widget _buildLoadingView() {
return Padding(
return const Padding(
padding: EdgeInsets.all(16),
child: SizedBox(
width: 30,
@@ -44,7 +44,7 @@ class HtmlViewerControllerForWeb {
void _evaluateJavascriptWeb({required Map<String, Object?> data}) async {
if (kIsWeb) {
data['view'] = _viewId;
final jsonEncoder = JsonEncoder();
const jsonEncoder = JsonEncoder();
var json = jsonEncoder.convert(data);
html.window.postMessage(json, '*');
} else {
@@ -64,7 +64,7 @@ class AvatarBuilder {
Widget build() {
return InkWell(
onTap: () => _onTapAvatarActionClick != null ? _onTapAvatarActionClick?.call() : null,
onTap: () => _onTapAvatarActionClick != null ? _onTapAvatarActionClick!.call() : null,
onTapDown: (detail) {
if (_onTapAvatarActionWithPositionClick != null && _context != null) {
final screenSize = MediaQuery.of(_context!).size;
@@ -96,7 +96,7 @@ class AvatarBuilder {
color: _bgColor ?? AppColor.avatarColor
),
child: Text(
'${_text ?? ''}',
_text ?? '',
style: _textStyle ?? TextStyle(fontSize: 20, color: _textColor ?? AppColor.avatarTextColor, fontWeight: FontWeight.w500)
)
),
@@ -6,7 +6,7 @@ typedef OnPressIconActionClick = void Function();
class IconBuilder {
Key? _key;
double? _size;
String? _icon;
final String? _icon;
EdgeInsets? _padding;
OnPressIconActionClick? _onPressIconActionClick;
@@ -34,7 +34,7 @@ class IconBuilder {
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
padding: _padding ?? EdgeInsets.all(3),
padding: _padding ?? const EdgeInsets.all(3),
child: Material(
borderRadius: BorderRadius.circular((_size ?? 40) / 2),
color: Colors.transparent,
@@ -6,9 +6,9 @@ class TreeView extends InheritedWidget {
TreeView({
Key? key,
required List<Widget> children,
bool startExpanded = false,
}) : this.children = children, this.startExpanded = startExpanded, super (
required this.children,
this.startExpanded = false,
}) : super (
key: key,
child: _TreeViewData(
children: children,
@@ -21,8 +21,8 @@ class TreeView extends InheritedWidget {
@override
bool updateShouldNotify(TreeView oldWidget) {
if (oldWidget.children == this.children &&
oldWidget.startExpanded == this.startExpanded) {
if (oldWidget.children == children &&
oldWidget.startExpanded == startExpanded) {
return false;
}
return true;
@@ -39,7 +39,7 @@ class _TreeViewData extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
key: PageStorageKey('tree_view'),
key: const PageStorageKey('tree_view'),
shrinkWrap: true,
primary: false,
padding: EdgeInsets.zero,
@@ -82,12 +82,12 @@ class TreeViewChild {
},
),
AnimatedContainer(
duration: Duration(milliseconds: 400),
duration: const Duration(milliseconds: 400),
child: isExpanded!
? Column(
mainAxisSize: MainAxisSize.min,
children: children.map((child) => Padding(padding: EdgeInsets.only(left: 20), child: child)).toList())
: Offstage(),
children: children.map((child) => Padding(padding: const EdgeInsets.only(left: 20), child: child)).toList())
: const Offstage(),
),
],
);
@@ -107,7 +107,7 @@ class EditTextModalSheetBuilder {
isScrollControlled: true,
context: context,
constraints: _constraints,
shape: RoundedRectangleBorder(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0))),
@@ -117,15 +117,15 @@ class EditTextModalSheetBuilder {
key: _key,
padding: MediaQuery.of(context).viewInsets,
child: Container(
padding: EdgeInsets.only(left: 50, right: 50, top: 48, bottom: 20),
padding: const EdgeInsets.only(left: 50, right: 50, top: 48, bottom: 20),
child: Wrap(
children: <Widget>[
Text(
_title,
style: TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
style: const TextStyle(fontSize: 20, color: AppColor.colorNameEmail, fontWeight: FontWeight.w700),
textAlign: TextAlign.center),
Padding(
padding: EdgeInsets.only(top: 20),
padding: const EdgeInsets.only(top: 20),
child: TextFormField(
keyboardType: TextInputType.visiblePassword,
onChanged: (value) => _onTextChanged(value, setState),
@@ -133,7 +133,7 @@ class EditTextModalSheetBuilder {
controller: _textController,
decoration: InputDecoration(
errorText: _error,
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
enabledBorder: const UnderlineInputBorder(borderSide: BorderSide(color: AppColor.colorDividerMailbox)),
hintText: _hintText),
)
),
@@ -142,7 +142,7 @@ class EditTextModalSheetBuilder {
children: [
TextButton(
onPressed: () => _onCancelButtonPress(context),
child: Text(_cancelText.toUpperCase(), style: TextStyle(color: AppColor.colorTextButton)),
child: Text(_cancelText.toUpperCase(), style: const TextStyle(color: AppColor.colorTextButton)),
),
TextButton(
onPressed: () => _onConfirmButtonPress(context),
@@ -11,30 +11,30 @@ class PopupMenuItemWidget extends StatelessWidget {
final Color? iconColor;
final String? iconSelection;
PopupMenuItemWidget(
const PopupMenuItemWidget(
this.icon,
this.name,
this.onTapCallback,
{
{Key? key,
this.iconSelection,
this.iconColor
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () => onTapCallback.call(),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 16),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: SizedBox(
child: Row(children: [
SvgPicture.asset(icon, width: 20, height: 20, fit: BoxFit.fill, color: iconColor),
SizedBox(width: 12),
const SizedBox(width: 12),
Expanded(child: Text(name,
style: TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500))),
style: const TextStyle(fontSize: 15, color: Colors.black, fontWeight: FontWeight.w500))),
if (iconSelection != null)
Padding(
padding: EdgeInsets.only(left: 12),
padding: const EdgeInsets.only(left: 12),
child: SvgPicture.asset(iconSelection!, width: 16, height: 16, fit: BoxFit.fill)),
])
),
@@ -4,6 +4,7 @@ import 'dart:math';
import 'dart:io';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/utils/app_logger.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -11,16 +12,16 @@ import 'package:flutter/services.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
typedef FutureOr<Iterable<T>> SuggestionsCallback<T>(String pattern);
typedef FutureOr<Iterable<R>> FetchRecentActionCallback<R>(String pattern);
typedef Widget ItemBuilder<T>(BuildContext context, T itemData);
typedef void SuggestionSelectionCallback<T>(T suggestion);
typedef void RecentSelectionCallback<R>(R recent);
typedef Widget ErrorBuilder(BuildContext context, Object? error);
typedef Widget ButtonActionBuilder(BuildContext context, dynamic action);
typedef void ButtonActionCallback(dynamic action);
typedef SuggestionsCallback<T> = FutureOr<Iterable<T>> Function(String pattern);
typedef FetchRecentActionCallback<R> = FutureOr<Iterable<R>> Function(String pattern);
typedef ItemBuilder<T> = Widget Function(BuildContext context, T itemData);
typedef SuggestionSelectionCallback<T> = void Function(T suggestion);
typedef RecentSelectionCallback<R> = void Function(R recent);
typedef ErrorBuilder = Widget Function(BuildContext context, Object? error);
typedef ButtonActionBuilder = Widget Function(BuildContext context, dynamic action);
typedef ButtonActionCallback = void Function(dynamic action);
typedef Widget AnimationTransitionBuilder(
typedef AnimationTransitionBuilder = Widget Function(
BuildContext context, Widget child, AnimationController? controller);
final supportedPlatform = (kIsWeb || Platform.isAndroid || Platform.isIOS);
@@ -42,40 +43,40 @@ class QuickSearchInputForm<T, R> extends FormField<String> {
QuickSearchInputForm(
{Key? key,
String? initialValue,
bool getImmediateSuggestions: false,
bool getImmediateSuggestions = false,
@Deprecated('Use autovalidateMode parameter which provides more specific '
'behavior related to auto validation. '
'This feature was deprecated after Flutter v1.19.0.')
bool autovalidate: false,
bool enabled: true,
AutovalidateMode autovalidateMode: AutovalidateMode.disabled,
bool autovalidate = false,
bool enabled = true,
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
FormFieldSetter<String>? onSaved,
FormFieldValidator<String>? validator,
ErrorBuilder? errorBuilder,
WidgetBuilder? noItemsFoundBuilder,
WidgetBuilder? loadingBuilder,
Duration debounceDuration: const Duration(milliseconds: 300),
QuickSearchSuggestionsBoxDecoration suggestionsBoxDecoration:
Duration debounceDuration = const Duration(milliseconds: 300),
QuickSearchSuggestionsBoxDecoration suggestionsBoxDecoration =
const QuickSearchSuggestionsBoxDecoration(),
QuickSearchSuggestionsBoxController? suggestionsBoxController,
required SuggestionSelectionCallback<T> onSuggestionSelected,
required ItemBuilder<T> itemBuilder,
required SuggestionsCallback<T> suggestionsCallback,
double suggestionsBoxVerticalOffset: 5.0,
this.textFieldConfiguration: const QuickSearchTextFieldConfiguration(),
double suggestionsBoxVerticalOffset = 5.0,
this.textFieldConfiguration = const QuickSearchTextFieldConfiguration(),
AnimationTransitionBuilder? transitionBuilder,
Duration animationDuration: const Duration(milliseconds: 500),
double animationStart: 0.25,
AxisDirection direction: AxisDirection.down,
bool hideOnLoading: false,
bool hideOnEmpty: false,
bool hideOnError: false,
bool hideSuggestionsOnKeyboardHide: true,
bool keepSuggestionsOnLoading: true,
bool keepSuggestionsOnSuggestionSelected: false,
bool autoFlipDirection: false,
bool hideKeyboard: false,
int minCharsForSuggestions: 0,
Duration animationDuration = const Duration(milliseconds: 500),
double animationStart = 0.25,
AxisDirection direction = AxisDirection.down,
bool hideOnLoading = false,
bool hideOnEmpty = false,
bool hideOnError = false,
bool hideSuggestionsOnKeyboardHide = true,
bool keepSuggestionsOnLoading = true,
bool keepSuggestionsOnSuggestionSelected = false,
bool autoFlipDirection = false,
bool hideKeyboard = false,
int minCharsForSuggestions = 0,
List<dynamic>? listActionButton,
ButtonActionBuilder? actionButtonBuilder,
ButtonActionCallback? buttonActionCallback,
@@ -85,7 +86,7 @@ class QuickSearchInputForm<T, R> extends FormField<String> {
FetchRecentActionCallback<R>? fetchRecentActionCallback,
RecentSelectionCallback<R>? onRecentSelected,
EdgeInsets? listActionPadding,
bool hideSuggestionsBox: false,
bool hideSuggestionsBox = false,
BoxDecoration? decoration,
double? maxHeight,
}) : assert(
@@ -189,13 +190,15 @@ class _TypeAheadFormFieldState<T, R> extends FormFieldState<String> {
?.addListener(_handleControllerChanged);
if (oldWidget.textFieldConfiguration.controller != null &&
widget.textFieldConfiguration.controller == null)
widget.textFieldConfiguration.controller == null) {
_controller = TextEditingController.fromValue(
oldWidget.textFieldConfiguration.controller!.value);
}
if (widget.textFieldConfiguration.controller != null) {
setValue(widget.textFieldConfiguration.controller!.text);
if (oldWidget.textFieldConfiguration.controller == null)
if (oldWidget.textFieldConfiguration.controller == null) {
_controller = null;
}
}
}
}
@@ -223,8 +226,9 @@ class _TypeAheadFormFieldState<T, R> extends FormFieldState<String> {
// notifications for changes originating from within this class -- for
// example, the reset() method. In such cases, the FormField value will
// already have been set.
if (_effectiveController!.text != value)
if (_effectiveController!.text != value) {
didChange(_effectiveController!.text);
}
}
}
@@ -516,34 +520,34 @@ class TypeAheadFieldQuickSearch<T, R> extends StatefulWidget {
final double? maxHeight;
/// Creates a [TypeAheadFieldQuickSearch]
TypeAheadFieldQuickSearch(
const TypeAheadFieldQuickSearch(
{Key? key,
required this.suggestionsCallback,
required this.itemBuilder,
required this.onSuggestionSelected,
this.textFieldConfiguration: const QuickSearchTextFieldConfiguration(),
this.suggestionsBoxDecoration: const QuickSearchSuggestionsBoxDecoration(),
this.debounceDuration: const Duration(milliseconds: 300),
this.textFieldConfiguration = const QuickSearchTextFieldConfiguration(),
this.suggestionsBoxDecoration = const QuickSearchSuggestionsBoxDecoration(),
this.debounceDuration = const Duration(milliseconds: 300),
this.suggestionsBoxController,
this.scrollController,
this.loadingBuilder,
this.noItemsFoundBuilder,
this.errorBuilder,
this.transitionBuilder,
this.animationStart: 0.25,
this.animationDuration: const Duration(milliseconds: 500),
this.getImmediateSuggestions: false,
this.suggestionsBoxVerticalOffset: 5.0,
this.direction: AxisDirection.down,
this.hideOnLoading: false,
this.hideOnEmpty: false,
this.hideOnError: false,
this.hideSuggestionsOnKeyboardHide: true,
this.keepSuggestionsOnLoading: true,
this.keepSuggestionsOnSuggestionSelected: false,
this.autoFlipDirection: false,
this.hideKeyboard: false,
this.minCharsForSuggestions: 0,
this.animationStart = 0.25,
this.animationDuration = const Duration(milliseconds: 500),
this.getImmediateSuggestions = false,
this.suggestionsBoxVerticalOffset = 5.0,
this.direction = AxisDirection.down,
this.hideOnLoading = false,
this.hideOnEmpty = false,
this.hideOnError = false,
this.hideSuggestionsOnKeyboardHide = true,
this.keepSuggestionsOnLoading = true,
this.keepSuggestionsOnSuggestionSelected = false,
this.autoFlipDirection = false,
this.hideKeyboard = false,
this.minCharsForSuggestions = 0,
this.listActionButton,
this.actionButtonBuilder,
this.buttonActionCallback,
@@ -595,13 +599,13 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
@override
void didChangeMetrics() {
// Catch keyboard event and orientation change; resize suggestions list
this._suggestionsBox!.onChangeMetrics();
_suggestionsBox!.onChangeMetrics();
}
@override
void dispose() {
this._suggestionsBox!.close();
this._suggestionsBox!.widgetMounted = false;
_suggestionsBox!.close();
_suggestionsBox!.widgetMounted = false;
WidgetsBinding.instance.removeObserver(this);
_keyboardVisibilitySubscription?.cancel();
_effectiveFocusNode!.removeListener(_focusNodeListener);
@@ -618,37 +622,37 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
WidgetsBinding.instance.addObserver(this);
if (widget.textFieldConfiguration.controller == null) {
this._textEditingController = TextEditingController();
_textEditingController = TextEditingController();
}
if (widget.textFieldConfiguration.focusNode == null) {
this._focusNode = FocusNode();
_focusNode = FocusNode();
}
this._suggestionsBox = _SuggestionsBox(
_suggestionsBox = _SuggestionsBox(
context,
widget.direction,
widget.autoFlipDirection,
widget.hideSuggestionsBox);
widget.suggestionsBoxController?._suggestionsBox = this._suggestionsBox;
widget.suggestionsBoxController?._suggestionsBox = _suggestionsBox;
widget.suggestionsBoxController?._effectiveFocusNode =
this._effectiveFocusNode;
_effectiveFocusNode;
this._focusNodeListener = () {
_focusNodeListener = () {
if (_effectiveFocusNode!.hasFocus) {
this._suggestionsBox!.open();
_suggestionsBox!.open();
} else {
if (widget.hideSuggestionsOnKeyboardHide){
this._suggestionsBox!.close();
_suggestionsBox!.close();
}
}
setState(() {});
};
this._effectiveFocusNode!.addListener(_focusNodeListener);
_effectiveFocusNode!.addListener(_focusNodeListener);
// hide suggestions box on keyboard closed
this._keyboardVisibilitySubscription =
_keyboardVisibilitySubscription =
_keyboardVisibility?.listen((bool isVisible) {
if (widget.hideSuggestionsOnKeyboardHide && !isVisible) {
_effectiveFocusNode!.unfocus();
@@ -657,13 +661,13 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
WidgetsBinding.instance.addPostFrameCallback((duration) {
if (mounted) {
this._initOverlayEntry();
_initOverlayEntry();
// calculate initial suggestions list size
this._suggestionsBox!.resize();
_suggestionsBox!.resize();
// in case we already missed the focus event
if (this._effectiveFocusNode!.hasFocus) {
this._suggestionsBox!.open();
if (_effectiveFocusNode!.hasFocus) {
_suggestionsBox!.open();
}
setState(() {});
}
@@ -699,12 +703,12 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
}
void _initOverlayEntry() {
this._suggestionsBox!._overlayEntry = OverlayEntry(builder: (context) {
_suggestionsBox!._overlayEntry = OverlayEntry(builder: (context) {
final suggestionsList = _SuggestionsList<T, R>(
suggestionsBox: _suggestionsBox,
decoration: widget.suggestionsBoxDecoration,
debounceDuration: widget.debounceDuration,
controller: this._effectiveController,
controller: _effectiveController,
loadingBuilder: widget.loadingBuilder,
scrollController: widget.scrollController,
noItemsFoundBuilder: widget.noItemsFoundBuilder,
@@ -716,8 +720,8 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
getImmediateSuggestions: widget.getImmediateSuggestions,
onSuggestionSelected: (T selection) {
if (!widget.keepSuggestionsOnSuggestionSelected) {
this._effectiveFocusNode!.unfocus();
this._suggestionsBox!.close();
_effectiveFocusNode!.unfocus();
_suggestionsBox!.close();
}
widget.onSuggestionSelected(selection);
},
@@ -737,8 +741,8 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
fetchRecentActionCallback: widget.fetchRecentActionCallback,
onRecentSelected: (R selection) {
if (!widget.keepSuggestionsOnSuggestionSelected) {
this._effectiveFocusNode!.unfocus();
this._suggestionsBox!.close();
_effectiveFocusNode!.unfocus();
_suggestionsBox!.close();
}
if (widget.onRecentSelected != null) {
widget.onRecentSelected!(selection);
@@ -770,7 +774,7 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
return Positioned(
width: w,
child: CompositedTransformFollower(
link: this._layerLink,
link: _layerLink,
showWhenUnlinked: false,
offset: Offset(
widget.suggestionsBoxDecoration.offsetX,
@@ -780,7 +784,7 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
child: _suggestionsBox!.direction == AxisDirection.down
? suggestionsList
: FractionalTranslation(
translation: Offset(0.0, -1.0), // visually flips list to go up
translation: const Offset(0.0, -1.0), // visually flips list to go up
child: suggestionsList,
),
),
@@ -791,9 +795,9 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
@override
Widget build(BuildContext context) {
return CompositedTransformTarget(
link: this._layerLink,
link: _layerLink,
child: Container(
decoration: this._suggestionsBox?.isOpened == true
decoration: _suggestionsBox?.isOpened == true
? const BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(16),
@@ -818,8 +822,8 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
widget.textFieldConfiguration.leftButton!,
Expanded(
child: TextField(
focusNode: this._effectiveFocusNode,
controller: this._effectiveController,
focusNode: _effectiveFocusNode,
controller: _effectiveController,
decoration: widget.textFieldConfiguration.decoration,
style: widget.textFieldConfiguration.style,
textAlign: widget.textFieldConfiguration.textAlign,
@@ -852,7 +856,7 @@ class _TypeAheadFieldQuickSearchState<T, R> extends State<TypeAheadFieldQuickSea
),
),
if (widget.textFieldConfiguration.clearTextButton != null
&& this._effectiveController?.text.isNotEmpty == true)
&& _effectiveController?.text.isNotEmpty == true)
widget.textFieldConfiguration.clearTextButton!,
if (widget.textFieldConfiguration.rightButton != null)
widget.textFieldConfiguration.rightButton!,
@@ -896,10 +900,10 @@ class _SuggestionsList<T, R> extends StatefulWidget {
final EdgeInsets? listActionPadding;
final bool hideSuggestionsBox;
_SuggestionsList({
const _SuggestionsList({
required this.suggestionsBox,
this.controller,
this.getImmediateSuggestions: false,
this.getImmediateSuggestions = false,
this.onSuggestionSelected,
this.suggestionsCallback,
this.itemBuilder,
@@ -927,7 +931,7 @@ class _SuggestionsList<T, R> extends StatefulWidget {
this.fetchRecentActionCallback,
this.onRecentSelected,
this.listActionPadding,
this.hideSuggestionsBox: false,
this.hideSuggestionsBox = false,
});
@override
@@ -948,14 +952,14 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
widget.scrollController ?? ScrollController();
_SuggestionsListState() {
this._controllerListener = () async {
_controllerListener = () async {
// If we came here because of a change in selected text, not because of
// actual change in text
if (widget.controller!.text == this._lastTextValue) return;
if (widget.controller!.text == _lastTextValue) return;
this._lastTextValue = widget.controller!.text;
_lastTextValue = widget.controller!.text;
this._debounceTimer?.cancel();
_debounceTimer?.cancel();
if (widget.controller!.text.length <= widget.minCharsForSuggestions!) {
if (mounted) {
Iterable<R>? recentItems;
@@ -963,7 +967,9 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
if (widget.fetchRecentActionCallback != null) {
recentItems = await widget.fetchRecentActionCallback!(widget.controller!.text);
}
} catch (e) {}
} catch (e) {
logError('_SuggestionsListState::_SuggestionsListState(): $e');
}
setState(() {
_isLoading = false;
@@ -974,17 +980,17 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
}
return;
} else {
this._debounceTimer = Timer(widget.debounceDuration!, () async {
if (this._debounceTimer!.isActive) return;
_debounceTimer = Timer(widget.debounceDuration!, () async {
if (_debounceTimer!.isActive) return;
if (_isLoading!) {
_isQueued = true;
return;
}
await this.invalidateSuggestions();
await invalidateSuggestions();
while (_isQueued!) {
_isQueued = false;
await this.invalidateSuggestions();
await invalidateSuggestions();
}
});
}
@@ -994,7 +1000,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
@override
void didUpdateWidget(_SuggestionsList<T, R> oldWidget) {
super.didUpdateWidget(oldWidget);
widget.controller!.addListener(this._controllerListener);
widget.controller!.addListener(_controllerListener);
_getSuggestions();
}
@@ -1008,21 +1014,21 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
void initState() {
super.initState();
this._animationController = AnimationController(
_animationController = AnimationController(
vsync: this,
duration: widget.animationDuration,
);
this._suggestionsValid = widget.minCharsForSuggestions! > 0 ? true : false;
this._isLoading = false;
this._isQueued = false;
this._lastTextValue = widget.controller!.text;
_suggestionsValid = widget.minCharsForSuggestions! > 0 ? true : false;
_isLoading = false;
_isQueued = false;
_lastTextValue = widget.controller!.text;
if (widget.getImmediateSuggestions) {
this._getSuggestions();
_getSuggestions();
}
widget.controller!.addListener(this._controllerListener);
widget.controller!.addListener(_controllerListener);
}
Future<void> invalidateSuggestions() async {
@@ -1037,9 +1043,9 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
if (mounted) {
setState(() {
this._animationController!.forward(from: 1.0);
_animationController!.forward(from: 1.0);
this._isLoading = true;
_isLoading = true;
});
Iterable<T>? suggestions;
@@ -1055,7 +1061,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
error = e;
}
if (this.mounted) {
if (mounted) {
// if it wasn't removed in the meantime
setState(() {
double? animationStart = widget.animationStart;
@@ -1063,11 +1069,11 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
if (error != null || suggestions?.isEmpty == true) {
animationStart = 1.0;
}
this._animationController!.forward(from: animationStart);
_animationController!.forward(from: animationStart);
this._isLoading = false;
this._suggestions = suggestions;
this._recentItems = recentItems;
_isLoading = false;
_suggestions = suggestions;
_recentItems = recentItems;
});
}
}
@@ -1083,23 +1089,23 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
@override
Widget build(BuildContext context) {
if (widget.hideSuggestionsBox) {
return SizedBox.shrink();
return const SizedBox.shrink();
}
Widget child;
if (this._suggestions?.isNotEmpty == true && widget.controller?.text.isNotEmpty == true) {
if (_suggestions?.isNotEmpty == true && widget.controller?.text.isNotEmpty == true) {
child = createSuggestionsWidget();
} else {
child = createRecentWidget();
}
final animationChild = widget.transitionBuilder != null
? widget.transitionBuilder!(context, child, this._animationController)
? widget.transitionBuilder!(context, child, _animationController)
: SizeTransition(
axisAlignment: -1.0,
sizeFactor: CurvedAnimation(
parent: this._animationController!,
parent: _animationController!,
curve: Curves.fastOutSlowIn),
child: child,
);
@@ -1141,7 +1147,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
}
Widget createSuggestionsWidget() {
final listItemSuggestionWidget = this._suggestions?.map((T suggestion) {
final listItemSuggestionWidget = _suggestions?.map((T suggestion) {
if ( widget.itemBuilder != null) {
return InkWell(
child: widget.itemBuilder!(context, suggestion),
@@ -1150,16 +1156,16 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
},
);
} else {
return SizedBox.shrink();
return const SizedBox.shrink();
}
}).toList() ?? [];
final loadingWidget = widget.loadingBuilder != null
? widget.loadingBuilder!(context)
: Align(
: const Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: EdgeInsets.symmetric(vertical: 8.0),
child: CircularProgressIndicator(),
),
);
@@ -1171,17 +1177,17 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
padding: const EdgeInsets.only(right: 8, bottom: kIsWeb ? 8 : 0),
child: InkWell(
child: widget.actionButtonBuilder!(context, action),
borderRadius: BorderRadius.all(Radius.circular(10)),
borderRadius: const BorderRadius.all(Radius.circular(10)),
onTap: () {
if (widget.buttonActionCallback != null) {
widget.buttonActionCallback!(action);
this.invalidateSuggestions();
invalidateSuggestions();
}
},
),
);
} else {
return SizedBox.shrink();
return const SizedBox.shrink();
}
}).toList());
@@ -1197,14 +1203,14 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
padding: widget.listActionPadding ?? EdgeInsets.zero,
child: listAction,
),
if (this._isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
if (_isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
loadingWidget,
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
widget.buttonShowAllResult!(context, widget.controller?.text),
if (listItemSuggestionWidget.isNotEmpty)
... [
... listItemSuggestionWidget,
SizedBox(height: 16)
const SizedBox(height: 16)
],
],
);
@@ -1220,7 +1226,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
}
Widget createRecentWidget() {
final listItemRecent = this._recentItems?.map((R recent) {
final listItemRecent = _recentItems?.map((R recent) {
if (widget.itemRecentBuilder != null) {
return InkWell(
child: widget.itemRecentBuilder!(context, recent),
@@ -1231,16 +1237,16 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
},
);
} else {
return SizedBox.shrink();
return const SizedBox.shrink();
}
}).toList() ?? [];
final loadingWidget = widget.loadingBuilder != null
? widget.loadingBuilder!(context)
: Align(
: const Align(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: EdgeInsets.symmetric(vertical: 8.0),
child: CircularProgressIndicator(),
),
);
@@ -1249,20 +1255,20 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
children: widget.listActionButton!.map((dynamic action) {
if (widget.actionButtonBuilder != null) {
return Padding(
padding: EdgeInsets.only(right: 8, bottom: kIsWeb ? 8 : 0),
padding: const EdgeInsets.only(right: 8, bottom: kIsWeb ? 8 : 0),
child: InkWell(
child: widget.actionButtonBuilder!(context, action),
borderRadius: BorderRadius.all(Radius.circular(10)),
borderRadius: const BorderRadius.all(Radius.circular(10)),
onTap: () {
if (widget.buttonActionCallback != null) {
widget.buttonActionCallback!(action);
this.invalidateSuggestions();
invalidateSuggestions();
}
},
),
);
} else {
return SizedBox.shrink();
return const SizedBox.shrink();
}
}).toList());
@@ -1278,7 +1284,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
padding: widget.listActionPadding ?? EdgeInsets.zero,
child: listAction,
),
if (this._isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
if (_isLoading == true && widget.hideOnLoading == false && widget.keepSuggestionsOnLoading == false)
loadingWidget,
if (widget.buttonShowAllResult != null && widget.controller?.text.isNotEmpty == true)
widget.buttonShowAllResult!(context, widget.controller?.text),
@@ -1287,7 +1293,7 @@ class _SuggestionsListState<T, R> extends State<_SuggestionsList<T, R>>
if (listItemRecent.isNotEmpty)
... [
... listItemRecent,
SizedBox(height: 16)
const SizedBox(height: 16)
],
],
);
@@ -1348,15 +1354,15 @@ class QuickSearchSuggestionsBoxDecoration {
/// Creates a QuickSearchSuggestionsBoxDecoration
const QuickSearchSuggestionsBoxDecoration(
{this.elevation: 4.0,
{this.elevation = 4.0,
this.color,
this.shape,
this.hasScrollbar: true,
this.hasScrollbar = true,
this.borderRadius,
this.shadowColor: const Color(0xFF000000),
this.shadowColor = const Color(0xFF000000),
this.constraints,
this.clipBehavior: Clip.none,
this.offsetX: 0.0});
this.clipBehavior = Clip.none,
this.offsetX = 0.0});
}
/// Supply an instance of this class to the [TypeAhead.textFieldConfiguration]
@@ -1533,36 +1539,36 @@ class QuickSearchTextFieldConfiguration {
/// Creates a QuickSearchTextFieldConfiguration
const QuickSearchTextFieldConfiguration({
this.decoration: const InputDecoration(),
this.decoration = const InputDecoration(),
this.style,
this.controller,
this.onChanged,
this.onSubmitted,
this.obscureText: false,
this.obscureText = false,
this.maxLengthEnforcement,
this.maxLength,
this.maxLines: 1,
this.maxLines = 1,
this.minLines,
this.textAlignVertical,
this.autocorrect: true,
this.autocorrect = true,
this.inputFormatters,
this.autofocus: false,
this.keyboardType: TextInputType.text,
this.enabled: true,
this.enableSuggestions: true,
this.textAlign: TextAlign.start,
this.autofocus = false,
this.keyboardType = TextInputType.text,
this.enabled = true,
this.enableSuggestions = true,
this.textAlign = TextAlign.start,
this.focusNode,
this.cursorColor,
this.cursorRadius,
this.textInputAction,
this.textCapitalization: TextCapitalization.none,
this.cursorWidth: 2.0,
this.textCapitalization = TextCapitalization.none,
this.cursorWidth = 2.0,
this.keyboardAppearance,
this.onEditingComplete,
this.onTap,
this.textDirection,
this.scrollPadding: const EdgeInsets.all(20.0),
this.enableInteractiveSelection: true,
this.scrollPadding = const EdgeInsets.all(20.0),
this.enableInteractiveSelection = true,
this.leftButton,
this.rightButton,
this.clearTextButton,
@@ -1670,26 +1676,26 @@ class _SuggestionsBox {
) : desiredDirection = direction;
void open() {
if (this.hideSuggestionBox) return;
if (this.isOpened) return;
assert(this._overlayEntry != null);
if (hideSuggestionBox) return;
if (isOpened) return;
assert(_overlayEntry != null);
resize();
Overlay.of(context)!.insert(this._overlayEntry!);
this.isOpened = true;
Overlay.of(context)!.insert(_overlayEntry!);
isOpened = true;
}
void close() {
if (!this.isOpened) return;
assert(this._overlayEntry != null);
this._overlayEntry!.remove();
this.isOpened = false;
if (!isOpened) return;
assert(_overlayEntry != null);
_overlayEntry!.remove();
isOpened = false;
}
void toggle() {
if (this.isOpened) {
this.close();
if (isOpened) {
close();
} else {
this.open();
open();
}
}
@@ -18,7 +18,7 @@ class SearchBarView extends StatelessWidget {
final Widget? rightButton;
final double? radius;
const SearchBarView(this._imagePaths, {
const SearchBarView(this._imagePaths, {Key? key,
this.heightSearchBar,
this.padding,
this.margin,
@@ -27,11 +27,12 @@ class SearchBarView extends StatelessWidget {
this.rightButton,
this.onOpenSearchViewAction,
this.radius,
});
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
key: Key('search_bar_widget'),
key: const Key('search_bar_widget'),
alignment: Alignment.center,
height: heightSearchBar ?? 40,
width: maxSizeWidth ?? double.infinity,
@@ -46,7 +47,7 @@ class SearchBarView extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 8),
const SizedBox(width: 8),
buildIconWeb(
splashRadius: 15,
minSize: 40,
@@ -63,7 +64,7 @@ class SearchBarView extends StatelessWidget {
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap,
style: TextStyle(
style: const TextStyle(
fontSize: kIsWeb ? 15 : 17,
color: AppColor.colorHintSearchBar)),
),
@@ -19,7 +19,7 @@ class CustomIndicator extends Decoration {
@override
_CustomPainter createBoxPainter([VoidCallback? onChanged]) {
return new _CustomPainter(this, onChanged);
return _CustomPainter(this, onChanged);
}
}
@@ -53,8 +53,8 @@ class _CustomPainter extends BoxPainter {
paint.style = PaintingStyle.fill;
canvas.drawRRect(
RRect.fromRectAndCorners(rect,
topRight: Radius.circular(8),
topLeft: Radius.circular(8)),
topRight: const Radius.circular(8),
topLeft: const Radius.circular(8)),
paint);
}
}
@@ -66,7 +66,7 @@ class SloganBuilder {
child: Column(children: [
_logoApp(),
Padding(
padding: _padding ?? EdgeInsets.only(top: 16, left: 16, right: 16),
padding: _padding ?? const EdgeInsets.only(top: 16, left: 16, right: 16),
child: Text(_text ?? '', key: _key, style: _textStyle, textAlign: _textAlign),
),
]),
@@ -77,7 +77,7 @@ class SloganBuilder {
child: Row(children: [
_logoApp(),
Padding(
padding: _padding ?? EdgeInsets.symmetric(horizontal: 10),
padding: _padding ?? const EdgeInsets.symmetric(horizontal: 10),
child: Text(_text ?? '', key: _key, style: _textStyle, textAlign: _textAlign),
),
]),
@@ -96,6 +96,6 @@ class SloganBuilder {
height: _sizeLogo ?? 150,
alignment: Alignment.center);
}
return SizedBox.shrink();
return const SizedBox.shrink();
}
}
@@ -28,13 +28,13 @@ class TextBuilder {
}
Text build() {
return Text(_text ?? '', key: _key ?? Key('TextBuilder'), style: _textStyle ?? CommonTextStyle.textStyleNormal, textAlign: _textAlign ?? TextAlign.center);
return Text(_text ?? '', key: _key ?? const Key('TextBuilder'), style: _textStyle ?? CommonTextStyle.textStyleNormal, textAlign: _textAlign ?? TextAlign.center);
}
}
class CenterTextBuilder extends TextBuilder {
@override
Text build() {
return Text(_text ?? '', key: _key ?? Key('TextBuilder'), style: _textStyle, textAlign: TextAlign.center);
return Text(_text ?? '', key: _key ?? const Key('TextBuilder'), style: _textStyle, textAlign: TextAlign.center);
}
}
@@ -79,7 +79,7 @@ class TextFieldBuilder {
TextField build() {
return TextField(
key: _key ?? Key('TextFieldBuilder'),
key: _key ?? const Key('TextFieldBuilder'),
onChanged: _onTextChange,
cursorColor: _cursorColor ?? AppColor.primaryColor,
controller: _textController,
@@ -89,7 +89,7 @@ class TextFieldBuilder {
maxLines: _maxLines,
minLines: _minLines,
keyboardAppearance: Brightness.light,
style: _textStyle ?? TextStyle(color: AppColor.textFieldTextColor),
style: _textStyle ?? const TextStyle(color: AppColor.textFieldTextColor),
obscureText: _obscureText ?? false,
keyboardType: _keyboardType,
onSubmitted: _onTextSubmitted,
+4 -4
View File
@@ -17,7 +17,7 @@ class FpsManager {
/// Threshold time consuming per frame
/// 1000/60hz ≈ 16.6ms 1000/120hz ≈ 8.3ms
Duration _thresholdPerFrame = Duration(microseconds: Duration.microsecondsPerSecond ~/ 60);
Duration _thresholdPerFrame = const Duration(microseconds: Duration.microsecondsPerSecond ~/ 60);
/// Refresh rate, default 60
double _refreshRate = 60;
@@ -31,7 +31,7 @@ class FpsManager {
}
bool _started = false;
List<FpsCallback> _fpsCallbacks = [];
final List<FpsCallback> _fpsCallbacks = [];
/// Temporarily save 120 frames
static const int _queue_capacity = 120;
@@ -102,9 +102,9 @@ class FpsManager {
int droppedCount = totalCount - drawFramesCount;
double fps = drawFramesCount / totalCount * _refreshRate;
FpsInfo fpsInfo = FpsInfo(fps, totalCount, droppedCount, drawFramesCount);
_fpsCallbacks.forEach((callBack) {
for (var callBack in _fpsCallbacks) {
callBack(fpsInfo);
});
}
}
}
}
+14
View File
@@ -195,6 +195,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_svg:
dependency: "direct main"
description:
@@ -254,6 +261,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
matcher:
dependency: transitive
description:
+1
View File
@@ -83,6 +83,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: 1.0.4
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
+1 -1
View File
@@ -278,7 +278,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.5"
json_annotation:
dependency: "direct main"
description:
+2 -1
View File
@@ -25,7 +25,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter_lints: 1.0.4
build_runner: 2.1.11
+29
View File
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
+14
View File
@@ -314,6 +314,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_svg:
dependency: transitive
description:
@@ -438,6 +445,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.2.0"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
logging:
dependency: transitive
description:
+2
View File
@@ -64,6 +64,8 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: 1.0.4
build_runner: 2.1.11
json_serializable: 6.2.0
+1 -1
View File
@@ -278,7 +278,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.5"
json_annotation:
dependency: "direct main"
description:
+2 -1
View File
@@ -25,7 +25,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter_lints: 1.0.4
build_runner: 2.1.11