cleanup code

This commit is contained in:
tzw
2024-01-23 16:28:08 +06:30
parent a1e87cdbf6
commit f3f75a80c6
96 changed files with 232 additions and 439 deletions

View File

@@ -1,7 +1,7 @@
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/material.dart';
Widget badgeCounter(Widget child, int counter) {
Widget badgeCounter(Widget child, int? counter) {
return Container(
width: 120,
child: new Stack(

View File

@@ -1,23 +0,0 @@
import 'package:flutter/cupertino.dart';
class BottomUpPageRoute<T> extends PageRouteBuilder<T> {
final Widget child;
BottomUpPageRoute(this.child)
: super(
pageBuilder: (context, animation, secondaryAnimation) => child,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
var begin = Offset(0.0, 1.0);
var end = Offset.zero;
var curve = Curves.ease;
var tween =
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
);
}

View File

@@ -4,7 +4,6 @@ import 'package:fcs/pages/term/term_page.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:provider/provider.dart';

View File

@@ -1,7 +1,6 @@
import 'package:fcs/domain/vo/delivery_address.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/delivery_address/delivery_address_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';

View File

@@ -1,6 +1,5 @@
import 'package:fcs/domain/entities/discount.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'local_text.dart';

View File

@@ -1,7 +1,6 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

View File

@@ -1,6 +1,4 @@
import 'dart:io';
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

View File

@@ -1,14 +1,13 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class InputDate extends StatelessWidget {
final String labelTextKey;
final IconData iconData;
final String? labelTextKey;
final IconData? iconData;
final TextEditingController controller;
final FormFieldValidator<String>? validator;
final int maxLines;
@@ -44,7 +43,7 @@ class InputDate extends StatelessWidget {
var dateFormatter = new DateFormat(dateFormatString);
FocusScope.of(context).unfocus();
var initialDate = DateTime.now();
if (controller != null) {
if (controller.text != "") {
try {
initialDate = dateFormatter.parse(controller.text);
} catch (e) {} // ignore error
@@ -55,7 +54,7 @@ class InputDate extends StatelessWidget {
lastDate: DateTime(2025),
initialDate: initialDate,
);
if (d != null && controller != null) {
if (d != null && controller.text != "") {
controller.text = dateFormatter.format(d);
}
},
@@ -72,7 +71,7 @@ class InputDate extends StatelessWidget {
),
labelText: labelTextKey == null
? null
: AppTranslations.of(context)!.text(labelTextKey),
: AppTranslations.of(context)!.text(labelTextKey!),
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),

View File

@@ -1,7 +1,6 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

View File

@@ -1,5 +1,4 @@
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'img_url.dart';
@@ -28,7 +27,7 @@ Widget labeledText(BuildContext context, String text, String label,
padding: EdgeInsets.only(top: 10),
// alignment: number ? Alignment.topRight : null,
child: Text(
text == null ? "" : text,
text,
style: textStyle,
maxLines: 3,
),

View File

@@ -1,6 +1,5 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';

View File

@@ -122,7 +122,6 @@ class _LocalPopupMenuButtonState extends State<LocalPopupMenuButton> {
bool _needHighlight() {
popmenus.forEach((e) {
if (e == null) return;
if (e.selected && e.highlight) return;
});
return false;

View File

@@ -1,5 +1,4 @@
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LocalRadioButtons<T> extends StatelessWidget {

View File

@@ -1,6 +1,5 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class LocalTitle extends StatelessWidget {

View File

@@ -15,7 +15,7 @@ class MultiImgController {
fileContainers = [];
}
set setImageUrls(List<String> imageUrls) {
set setImageUrls(List<String>? imageUrls) {
if (imageUrls == null) {
return;
}
@@ -30,7 +30,7 @@ class MultiImgController {
}
}
set setImageFiles(List<File> imageFiles) {
set setImageFiles(List<File>? imageFiles) {
if (imageFiles == null) {
return;
}

View File

@@ -1,9 +1,9 @@
// ignore_for_file: unnecessary_null_comparison, dead_code
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
/// Signature for [MyDataColumn.onSort] callback.
typedef MyDataColumnSortCallback = void Function(
@@ -13,7 +13,7 @@ typedef MyDataColumnSortCallback = void Function(
///
/// One column configuration must be provided for each column to
/// display in the table. The list of [MyDataColumn] objects is passed
/// as the `columns` argument to the [new MyDataTable] constructor.
/// as the `columns` argument to the [MyDataTable.new] constructor.
@immutable
class MyDataColumn {
/// Creates the configuration for a column of a [MyDataTable].
@@ -62,7 +62,7 @@ class MyDataColumn {
///
/// One row configuration must be provided for each row to
/// display in the table. The list of [MyDataRow] objects is passed
/// as the `rows` argument to the [new MyDataTable] constructor.
/// as the `rows` argument to the [MyDataTable.new] constructor.
///
/// The data for this row of the table is provided in the [cells]
/// property of the [MyDataRow] object.
@@ -137,7 +137,7 @@ class MyDataRow {
/// The data for a cell of a [MyDataTable].
///
/// One list of [MyDataCell] objects must be provided for each [MyDataRow]
/// in the [MyDataTable], in the [new MyDataRow] constructor's `cells`
/// in the [MyDataTable], in the [MyDataRow.new] constructor's `cells`
/// argument.
@immutable
class MyDataCell {
@@ -314,19 +314,18 @@ class MyDataTable extends StatelessWidget {
this.sortColumnIndex,
this.sortAscending = true,
this.onSelectAll,
this.MyDataRowHeight = kMinInteractiveDimension,
this.myDataRowHeight = kMinInteractiveDimension,
this.headingRowHeight = 56.0,
this.horizontalMargin = 24.0,
this.columnSpacing = 56.0,
this.oddLine,
this.evenLine,
required this.rows,
}) : assert(columns != null),
assert(columns.isNotEmpty),
}) : assert(columns.isNotEmpty),
assert(sortColumnIndex == null ||
(sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
assert(sortAscending != null),
assert(MyDataRowHeight != null),
assert(myDataRowHeight != null),
assert(headingRowHeight != null),
assert(horizontalMargin != null),
assert(columnSpacing != null),
@@ -382,7 +381,7 @@ class MyDataTable extends StatelessWidget {
///
/// This value defaults to kMinInteractiveDimension to adhere to the Material
/// Design specifications.
final double MyDataRowHeight;
final double myDataRowHeight;
/// The height of the heading row.
///
@@ -567,7 +566,7 @@ class MyDataTable extends StatelessWidget {
}
label = Container(
padding: padding,
height: MyDataRowHeight,
height: myDataRowHeight,
alignment: (numeric ?? false)
? Alignment.centerRight
: AlignmentDirectional.centerStart,
@@ -605,7 +604,6 @@ class MyDataTable extends StatelessWidget {
Widget build(BuildContext context) {
assert(!_debugInteractive || debugCheckHasMaterial(context));
final ThemeData theme = Theme.of(context);
final BoxDecoration _kSelectedDecoration = BoxDecoration(
border: Border(bottom: Divider.createBorderSide(context, width: 1.0)),
// The backgroundColor has to be transparent so you can see the ink on the material
@@ -618,7 +616,6 @@ class MyDataTable extends StatelessWidget {
);
final bool showCheckboxColumn = false;
final bool allChecked = false;
final List<TableColumnWidth> tableColumns = (columns.length +
(showCheckboxColumn ? 1 : 0)) as List<TableColumnWidth>;
@@ -641,7 +638,7 @@ class MyDataTable extends StatelessWidget {
int rowIndex;
int displayColumnIndex = 0;
int displayColumnIndex = 0;
// if (showCheckboxColumn) {
// tableColumns[0] = FixedColumnWidth(
// horizontalMargin + Checkbox.width + horizontalMargin / 2.0);
@@ -696,7 +693,7 @@ class MyDataTable extends StatelessWidget {
} else {
tableColumns[displayColumnIndex] = const IntrinsicColumnWidth();
}
tableRows[0].children![displayColumnIndex] = _buildHeadingCell(
tableRows[0].children[displayColumnIndex] = _buildHeadingCell(
context: context,
padding: padding,
label: column.label,
@@ -712,7 +709,7 @@ class MyDataTable extends StatelessWidget {
rowIndex = 1;
for (MyDataRow row in rows) {
final MyDataCell cell = row.cells[MyDataColumnIndex];
tableRows[rowIndex].children?[displayColumnIndex] = _buildMyDataCell(
tableRows[rowIndex].children[displayColumnIndex] = _buildMyDataCell(
context: context,
padding: padding,
label: cell.child,
@@ -780,13 +777,13 @@ class TableRowInkWell extends InkResponse {
parentBox.applyPaintTransform(cell, transform);
assert(table == cell.parent);
cell = parentBox;
table = table?.parent;
table = table.parent;
}
if (table is RenderTable) {
final TableCellParentData cellParentData =
cell.parentData as TableCellParentData;
assert(cellParentData.y != null);
final Rect rect = table .getRowBox(cellParentData.y!);
final Rect rect = table.getRowBox(cellParentData.y!);
// The rect is in the table's coordinate space. We need to change it to the
// TableRowInkWell's coordinate space.
table.applyPaintTransform(cell, transform);

View File

@@ -13,8 +13,7 @@ class NumberCell extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Text(
this.number == null ? '0' : numberFormatter.format(this.number),
return new Text(numberFormatter.format(this.number),
style: textStyle == null ? theme.textStyle : textStyle);
}
}

View File

@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:progress/progress.dart';
import 'package:provider/provider.dart';
import 'package:fcs/helpers/theme.dart';
class LocalProgress extends Progress {

View File

@@ -1,8 +1,6 @@
import 'package:fcs/domain/constants.dart';
import 'package:fcs/domain/entities/package.dart';
import 'package:fcs/domain/vo/shipment_status.dart';
import 'package:fcs/helpers/theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:intl/intl.dart';

View File

@@ -1,8 +1,6 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
typedef BtnCallback();

View File

@@ -1,6 +1,5 @@
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'callbacks.dart';