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