phase3: nullfix.py batch script — bang/late/param-nullable
Automated null-safety fixes driven by dart analyze (no corruption): - unchecked_use_of_nullable_value: insert '!' on receiver (property/method/[]/op) - not_initialized field/var: mark 'late' - missing_default_value_for_parameter: nullable param Errors: 2374(peak) -> 907
This commit is contained in:
@@ -40,7 +40,7 @@ class AddRemoveButton extends StatefulWidget {
|
||||
}
|
||||
|
||||
class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
int _qty;
|
||||
late int _qty;
|
||||
var zeroColor = const Color(0xFFEFEFEF);
|
||||
var qtyColor = const Color(0xFFFF6666);
|
||||
var zeroFontColor = const Color(0xFF888888);
|
||||
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
var d = 1;
|
||||
|
||||
CartInfo cartInfo;
|
||||
late CartInfo cartInfo;
|
||||
|
||||
GlobalKey startKey = GlobalKey();
|
||||
|
||||
@@ -63,10 +63,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id
|
||||
&& cartInfo.productList[i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product.id
|
||||
&& cartInfo.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (widget.product.leftNum <= 0) {
|
||||
if (widget.product.leftNum! <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
|
||||
child: Text(
|
||||
@@ -104,9 +104,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -197,15 +197,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business);
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList.length; i++) {
|
||||
if (cartInfo.productList[i].product.id == widget.product.id) {
|
||||
_qty = cartInfo.productList[i].quantity.round();
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widget.product.productAttributes != null &&
|
||||
widget.product.productAttributes.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
widget.product.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
return new Row(
|
||||
key: startKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
@@ -312,7 +312,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _addToCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity + 1.0 > widget.product.leftNum) {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! + 1.0 > widget.product.leftNum) {
|
||||
Fluttertoast.showToast(
|
||||
msg: S.of(context).product_insufficient,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -321,14 +321,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
textColor: Colors.white
|
||||
);
|
||||
} else {
|
||||
cartInfo.productList[widget.cartLineItemIndex].quantity += 1.0;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex]);
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity += 1.0;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex]);
|
||||
store.dispatch(UpdateCartInfo(
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
} else {
|
||||
if (widget.product.productAttributes.length > 0) {
|
||||
if (widget.product.productAttributes!.length > 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) =>
|
||||
@@ -345,7 +345,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _removeFromCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -380,15 +380,15 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
}
|
||||
|
||||
void _removeCartLineItem() {
|
||||
if (cartInfo.productList[widget.cartLineItemIndex].quantity <= 1) {
|
||||
String uuid = cartInfo.productList[widget.cartLineItemIndex].uuid;
|
||||
cartInfo.productList.removeAt(widget.cartLineItemIndex);
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid;
|
||||
cartInfo.productList!.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo, uuid);
|
||||
} else {
|
||||
cartInfo.productList[widget.cartLineItemIndex].quantity -= 1;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList[widget.cartLineItemIndex], remove: true);
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity -= 1;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex], remove: true);
|
||||
}
|
||||
if (cartInfo.productList.length <= 0) {
|
||||
if (cartInfo.productList!.length <= 0) {
|
||||
store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
} else {
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'popup_animation_widget.dart';
|
||||
|
||||
class AnimationPointManager {
|
||||
List<AnimatedWidget> list = [];
|
||||
static AnimationController controller1;
|
||||
static AnimationController controller2;
|
||||
static late AnimationController controller1;
|
||||
static late AnimationController controller2;
|
||||
|
||||
Future<void> addParabolicAniamtion({
|
||||
@required TickerProvider vsync,
|
||||
@@ -55,9 +55,9 @@ class AnimationPointManager {
|
||||
@required GlobalKey stackKey,
|
||||
@required GlobalKey startKey,
|
||||
@required Widget child,
|
||||
Duration duration,
|
||||
Duration? duration,
|
||||
Offset popupOffset = Offset.zero,
|
||||
AnimationStatusListener statusListener,
|
||||
AnimationStatusListener? statusListener,
|
||||
}) async {
|
||||
controller2 = createController(vsync, duration);
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).check_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).check_option_select_token(product.productAttributes![this.index].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -95,20 +95,20 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name);
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name);
|
||||
if (idx != -1) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx);
|
||||
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt);
|
||||
(cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx);
|
||||
} else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt);
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
|
||||
}
|
||||
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
|
||||
}
|
||||
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, false);
|
||||
|
||||
setState(() {
|
||||
selections = cloneSelections;
|
||||
@@ -121,20 +121,20 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product.productAttributes![index].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product.productAttributes![index].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product.productAttributes![index].name] = optionState;
|
||||
}
|
||||
|
||||
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
|
||||
|
||||
Map<String, dynamic> attrExtraJson = Utils.stringToJson(
|
||||
product.productAttributes[index].extra);
|
||||
product.productAttributes![index].extra);
|
||||
if (attrExtraJson != null) {
|
||||
var selectLimitIfFieldEqualsTo = Rule.getRule(
|
||||
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
|
||||
@@ -147,7 +147,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -168,7 +168,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -195,12 +195,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
|
||||
if (exclusiveRule != null) {
|
||||
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = true;
|
||||
optionsState[product.productAttributes![index].name][i]['disabled'] = true;
|
||||
} else {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(
|
||||
product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index]
|
||||
product.productAttributes![index].name, true);
|
||||
optionsState[product.productAttributes![index]
|
||||
.name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
@@ -208,12 +208,12 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
if (multiItemRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes[index]
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes![index]
|
||||
.name][i]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
@@ -222,26 +222,26 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionCheck(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i);
|
||||
product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
void disableOptionIfNotSelected() {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes![index].name][i]['disabled'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -343,7 +343,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
(productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
style: new TextStyle(
|
||||
fontSize: 11.0,
|
||||
color: check ? selectedTextColor : new Color(0xFFABABAB),
|
||||
@@ -354,7 +354,7 @@ class CheckOptionsState extends OptionsBaseState<CheckOptions> {
|
||||
),
|
||||
),
|
||||
onTap: () => disabled ? null : _onOptionTappedCallback(
|
||||
productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption),
|
||||
productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ abstract class OptionsBase extends StatefulWidget {
|
||||
}
|
||||
|
||||
abstract class OptionsBaseState<Base extends OptionsBase> extends State<Base> {
|
||||
Product product;
|
||||
Map<String, dynamic> selections;
|
||||
int index;
|
||||
late Product product;
|
||||
late Map<String, dynamic> selections;
|
||||
late int index;
|
||||
|
||||
final Color disabledBackgroundColor = new Color(0xFFBCBCBC);
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).check_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).check_option_select_token(product.productAttributes![this.index].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
product.productAttributes![this.index].required ? S.of(context).check_option_is_required : S.of(context).check_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -86,33 +86,33 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes[index].name, name);
|
||||
int idx = Utils.selectionsContains(cloneSelections, product.productAttributes![index].name, name);
|
||||
if (idx != -1) {
|
||||
if (quantity == 1) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] += 1;
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] += 1;
|
||||
optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
|
||||
} else {
|
||||
if (cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] - 1 > 0) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'] -= 1;
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
if (cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] - 1 > 0) {
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'] -= 1;
|
||||
optionsState[product.productAttributes![index].name][optIndex]['quantity'] = cloneSelections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
|
||||
} else {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).removeAt(idx);
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 0;
|
||||
(cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).removeAt(idx);
|
||||
optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 0;
|
||||
}
|
||||
}
|
||||
} else if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).add(opt);
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1;
|
||||
} else if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
|
||||
(cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).add(opt);
|
||||
optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1;
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
optionsState[product.productAttributes[index].name][optIndex]['quantity'] = 1;
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
|
||||
optionsState[product.productAttributes![index].name][optIndex]['quantity'] = 1;
|
||||
}
|
||||
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes[index].name.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (idx != -1 && (cloneSelections[product.productAttributes![index].name!.toUpperCase()] as List).length == 0) {
|
||||
cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
|
||||
}
|
||||
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, false);
|
||||
|
||||
setState(() {
|
||||
selections = cloneSelections;
|
||||
@@ -125,24 +125,24 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product.productAttributes![index].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product.productAttributes![index].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
int qty = 0;
|
||||
int idx = Utils.selectionsContains(selections, product.productAttributes[index].name, productOptions[i].name);
|
||||
int idx = Utils.selectionsContains(selections, product.productAttributes![index].name, productOptions[i].name);
|
||||
if (idx != -1) {
|
||||
qty = selections[product.productAttributes[index].name.toUpperCase()][idx]['quantity'];
|
||||
qty = selections[product.productAttributes![index].name!.toUpperCase()][idx]['quantity'];
|
||||
}
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'quantity': qty, 'check': false});
|
||||
optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'quantity': qty, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product.productAttributes![index].name] = optionState;
|
||||
}
|
||||
|
||||
if (selections.containsKey(product.productAttributes[index].name.toUpperCase())) {
|
||||
if (selections.containsKey(product.productAttributes![index].name!.toUpperCase())) {
|
||||
Map<String, dynamic> attrExtraJson = Utils.stringToJson(
|
||||
product.productAttributes[index].extra);
|
||||
product.productAttributes![index].extra);
|
||||
if (attrExtraJson != null) {
|
||||
var selectLimitIfFieldEqualsTo = Rule.getRule(
|
||||
attrExtraJson, Rule.RULE_SELECT_LIMIT_IF_FIELD_EQUALS_TO);
|
||||
@@ -155,7 +155,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
if (selectLimitIfFieldEqualsTo1.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo1[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo1[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Rule
|
||||
.RULE_KEY_FORCE_LIMITED];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
if (selectLimitIfFieldEqualsTo.containsKey(Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0])) {
|
||||
int limitQty = selectLimitIfFieldEqualsTo[Utils.getSelectedAttributeValue(selections, selectLimitIfFieldEqualsTo[Rule.RULE_KEY_FIELD_KEY])[0]];
|
||||
thisLimitQty = limitQty;
|
||||
if ((selections[product.productAttributes[index].name
|
||||
if ((selections[product.productAttributes![index].name
|
||||
.toUpperCase()] as List).length >= limitQty) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
@@ -203,12 +203,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
Map<String, dynamic> multiItemRule = Rule.getRule(extraJson, Rule.RULE_ACTUAL_QTY_IS);
|
||||
if (exclusiveRule != null) {
|
||||
if (thisLimitQty > 0 && !_checkOptionIsCheck(productOptions[i].name)) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = true;
|
||||
optionsState[product.productAttributes![index].name][i]['disabled'] = true;
|
||||
} else {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(
|
||||
product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index]
|
||||
product.productAttributes![index].name, true);
|
||||
optionsState[product.productAttributes![index]
|
||||
.name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
@@ -216,12 +216,12 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
if (multiItemRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
|
||||
disableOptionIfNotSelected();
|
||||
}
|
||||
} else {
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes[index].name.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes[index]
|
||||
if (multiItemRule[Rule.RULE_ACTUAL_QTY_IS] > thisLimitQty - (selections[product.productAttributes![index].name!.toUpperCase()] as List).length) {
|
||||
optionsState[product.productAttributes![index]
|
||||
.name][i]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
@@ -230,26 +230,26 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionQty(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], optionState[i]['quantity'], i);
|
||||
product.productAttributes![index].productOptions![i], optionState[i]['disabled'], optionState[i]['quantity'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
void disableOptionIfNotSelected() {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes[index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, optionsState[product.productAttributes[index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, true);
|
||||
for (var i = 0; i < optionsState[product.productAttributes![index].name].length; i++) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes![index].name, optionsState[product.productAttributes![index].name][i]['name']) != -1) {
|
||||
optionsState[product.productAttributes![index].name][i]['disabled'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -361,7 +361,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
(productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
style: new TextStyle(
|
||||
fontSize: 11.0,
|
||||
color: check ? selectedTextColor : new Color(0xFFABABAB),
|
||||
@@ -372,7 +372,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
),
|
||||
),
|
||||
onTap: () => disabled ? null : _onOptionTappedCallback(
|
||||
productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption),
|
||||
productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
|
||||
),
|
||||
new Container(
|
||||
width: 100.0,
|
||||
@@ -406,7 +406,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
),
|
||||
),
|
||||
onTap: () => disabled ? null : _onOptionTappedCallback(
|
||||
productOption.name, 1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption),
|
||||
productOption.name, 1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
|
||||
),
|
||||
),
|
||||
new Expanded(
|
||||
@@ -420,7 +420,7 @@ class QtyOptionsState extends OptionsBaseState<QtyOptions> {
|
||||
),
|
||||
),
|
||||
onTap: () => (disabled || quantity == 0) ? null : _onOptionTappedCallback(
|
||||
productOption.name, -1, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption),
|
||||
productOption.name, -1, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -40,14 +40,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new Text(
|
||||
S.of(context).radio_option_select_token(product.productAttributes[this.index].name),
|
||||
S.of(context).radio_option_select_token(product.productAttributes![this.index].name),
|
||||
style: new TextStyle(
|
||||
fontSize: 12.5,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
product.productAttributes[this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
||||
product.productAttributes![this.index].required ? S.of(context).radio_option_is_required : S.of(context).radio_option_is_optional,
|
||||
style: new TextStyle(
|
||||
fontSize: 10.0,
|
||||
color: new Color(0xFF999999)
|
||||
@@ -85,14 +85,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
'adjust_amount': adjustAmount
|
||||
};
|
||||
var cloneSelections = json.decode(json.encode(selections));
|
||||
if (product.productAttributes[index].required) {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
if (product.productAttributes![index].required) {
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
|
||||
} else {
|
||||
if (cloneSelections.containsKey(product.productAttributes[index].name.toUpperCase())
|
||||
&& Utils.equalsIgnoreCase(cloneSelections[product.productAttributes[index].name.toUpperCase()][0]['name'], name)) {
|
||||
cloneSelections.remove(product.productAttributes[index].name.toUpperCase());
|
||||
if (cloneSelections.containsKey(product.productAttributes![index].name!.toUpperCase())
|
||||
&& Utils.equalsIgnoreCase(cloneSelections[product.productAttributes![index].name!.toUpperCase()][0]['name'], name)) {
|
||||
cloneSelections.remove(product.productAttributes![index].name!.toUpperCase());
|
||||
} else {
|
||||
cloneSelections[product.productAttributes[index].name.toUpperCase()] = [opt];
|
||||
cloneSelections[product.productAttributes![index].name!.toUpperCase()] = [opt];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
|
||||
if (exclusiveRule != null) {
|
||||
if (_checkOptionIsCheck(productOption.name)) {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, false);
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,14 +118,14 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
children: <Widget>[],
|
||||
);
|
||||
|
||||
List<ProductOption> productOptions = product.productAttributes[index].productOptions;
|
||||
List<ProductOption> productOptions = product.productAttributes![index].productOptions;
|
||||
|
||||
if (!optionsState.containsKey(product.productAttributes[index].name)) {
|
||||
if (!optionsState.containsKey(product.productAttributes![index].name)) {
|
||||
List<Map<String, dynamic>> optionState = [];
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
optionState.add({'name': product.productAttributes[index].productOptions[i].name, 'disabled': false, 'check': false});
|
||||
optionState.add({'name': product.productAttributes![index].productOptions![i].name, 'disabled': false, 'check': false});
|
||||
}
|
||||
optionsState[product.productAttributes[index].name] = optionState;
|
||||
optionsState[product.productAttributes![index].name] = optionState;
|
||||
}
|
||||
|
||||
for (var i = 0; i < productOptions.length; i++) {
|
||||
@@ -135,25 +135,25 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
extraJson, Rule.RULE_EXCLUSIVE_SELECTION);
|
||||
if (exclusiveRule != null) {
|
||||
if (_checkOptionIsCheck(productOptions[i].name)) {
|
||||
setOptionsStateDisabled(product.productAttributes[index].name, true);
|
||||
optionsState[product.productAttributes[index].name][i]['disabled'] = false;
|
||||
setOptionsStateDisabled(product.productAttributes![index].name, true);
|
||||
optionsState[product.productAttributes![index].name][i]['disabled'] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes[index].name];
|
||||
List<Map<String, dynamic>> optionState = optionsState[product.productAttributes![index].name];
|
||||
for (var i = 0; i < optionState.length; i++) {
|
||||
Widget optionWidget = _getOptionRadio(
|
||||
product.productAttributes[index].productOptions[i], optionState[i]['disabled'], i);
|
||||
product.productAttributes![index].productOptions![i], optionState[i]['disabled'], i);
|
||||
row.children.add(optionWidget);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
bool _checkOptionIsCheck(String name) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes[index].name, name) != -1) {
|
||||
if (Utils.selectionsContains(selections, product.productAttributes![index].name, name) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -255,7 +255,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
new Text(
|
||||
(productOption.adjustAmount + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
(productOption.adjustAmount! + extraAdjustAmount) > 0 ? '+${(productOption.adjustAmount! + extraAdjustAmount).toStringAsFixed(2)}' : '',
|
||||
style: new TextStyle(
|
||||
fontSize: 11.0,
|
||||
color: check ? selectedTextColor : new Color(0xFFABABAB),
|
||||
@@ -266,7 +266,7 @@ class RadioOptionsState extends OptionsBaseState<RadioOptions> {
|
||||
),
|
||||
),
|
||||
onTap: () => disabled ? null : _onOptionTappedCallback(
|
||||
productOption.name, 0, productOption.adjustAmount + extraAdjustAmount, optIndex, productOption),
|
||||
productOption.name, 0, productOption.adjustAmount! + extraAdjustAmount, optIndex, productOption),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'style.dart';
|
||||
class Carousel extends StatefulWidget {
|
||||
Carousel({
|
||||
double height = 200.0,
|
||||
List<Widget> pages,
|
||||
bool autoPlay,
|
||||
List<Widget>? pages,
|
||||
bool? autoPlay,
|
||||
Duration duration = const Duration(seconds: 2),
|
||||
Duration animationDuration = const Duration(milliseconds: 1000),
|
||||
})
|
||||
@@ -30,7 +30,7 @@ class Carousel extends StatefulWidget {
|
||||
class CarouselState extends State<Carousel> {
|
||||
final _pageController = new PageController();
|
||||
|
||||
Timer _timer;
|
||||
late Timer _timer;
|
||||
int _currentPage = 0;
|
||||
bool reverse = false;
|
||||
GlobalKey<IndicatorState> _indicatorStateKey = new GlobalKey();
|
||||
@@ -80,7 +80,7 @@ class CarouselState extends State<Carousel> {
|
||||
children: widget.pages,
|
||||
onPageChanged: (index) {
|
||||
_currentPage = index;
|
||||
_indicatorStateKey.currentState.changeIndex(index);
|
||||
_indicatorStateKey.currentState!.changeIndex(index);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -102,7 +102,7 @@ class CarouselState extends State<Carousel> {
|
||||
}
|
||||
|
||||
class Indicator extends StatefulWidget {
|
||||
Indicator({Key? key, int count})
|
||||
Indicator({Key? key, int? count})
|
||||
: count = count,
|
||||
super(key: key);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class ETransferPay extends StatelessWidget {
|
||||
fontSize: 15, color: Colors.black54),
|
||||
),
|
||||
Text(
|
||||
'\$${order.totalPrice.toStringAsFixed(2)}',
|
||||
'\$${order.totalPrice!.toStringAsFixed(2)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
||||
@@ -11,7 +11,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
final Offset startAdjustOffset;
|
||||
final Offset endAdjustOffset;
|
||||
|
||||
ParabolicAnimationWidget({
|
||||
late ParabolicAnimationWidget({
|
||||
@required Animation<double> animation,
|
||||
@required this.stackKey,
|
||||
@required this.startKey,
|
||||
@@ -66,17 +66,17 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
|
||||
void _calPoints() {
|
||||
if (_startOffset == null) {
|
||||
RenderBox stackBox = stackKey.currentContext.findRenderObject();
|
||||
RenderBox stackBox = stackKey.currentContext!.findRenderObject();
|
||||
Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
|
||||
|
||||
EdgeInsets startMargin = _margin(startKey);
|
||||
RenderBox startBox = startKey.currentContext.findRenderObject();
|
||||
RenderBox startBox = startKey.currentContext!.findRenderObject();
|
||||
_startOffset = startBox.localToGlobal(Offset(
|
||||
startMargin.left + startAdjustOffset.dx,
|
||||
stackBoxOffset.dy + startMargin.top + startAdjustOffset.dy));
|
||||
|
||||
EdgeInsets endMargin = _margin(endKey);
|
||||
RenderBox endBox = endKey.currentContext.findRenderObject();
|
||||
RenderBox endBox = endKey.currentContext!.findRenderObject();
|
||||
_endOffset = endBox.localToGlobal(Offset(
|
||||
endMargin.left + endAdjustOffset.dx,
|
||||
stackBoxOffset.dy + endMargin.top + endAdjustOffset.dy));
|
||||
@@ -84,7 +84,7 @@ class ParabolicAnimationWidget extends AnimatedWidget {
|
||||
}
|
||||
|
||||
EdgeInsets _margin(GlobalKey key) {
|
||||
final Widget widget = key.currentContext.widget;
|
||||
final Widget widget = key.currentContext!.widget;
|
||||
EdgeInsets margin = (widget is Container) ? widget.margin : EdgeInsets.zero;
|
||||
return margin ?? EdgeInsets.zero;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ class PaymentVerificationCodeDialogState extends State<PaymentVerificationCodeDi
|
||||
String getCodeText = '';
|
||||
String paymentCodeEncrypt = '';
|
||||
|
||||
String verifyMethod;
|
||||
String verifyName;
|
||||
late String verifyMethod;
|
||||
late String verifyName;
|
||||
|
||||
final TextEditingController _pinPutController = TextEditingController();
|
||||
final FocusNode _pinPutFocusNode = FocusNode();
|
||||
|
||||
@@ -9,7 +9,7 @@ class PopupAnimationWidget extends AnimatedWidget {
|
||||
final Offset popupOffset;
|
||||
final Animation<double> animation;
|
||||
|
||||
PopupAnimationWidget({
|
||||
late PopupAnimationWidget({
|
||||
@required this.animation,
|
||||
@required this.stackKey,
|
||||
@required this.startKey,
|
||||
@@ -49,11 +49,11 @@ class PopupAnimationWidget extends AnimatedWidget {
|
||||
|
||||
void _calAnimation() {
|
||||
if (_startOffset == null) {
|
||||
final RenderBox stackBox = stackKey.currentContext.findRenderObject();
|
||||
final RenderBox stackBox = stackKey.currentContext!.findRenderObject();
|
||||
final Offset stackBoxOffset = stackBox.globalToLocal(Offset.zero);
|
||||
|
||||
final EdgeInsets startMargin = _margin(startKey);
|
||||
final RenderBox startBox = startKey.currentContext.findRenderObject();
|
||||
final RenderBox startBox = startKey.currentContext!.findRenderObject();
|
||||
|
||||
_startOffset = startBox.localToGlobal(Offset(
|
||||
startMargin.left + popupOffset.dx,
|
||||
@@ -62,7 +62,7 @@ class PopupAnimationWidget extends AnimatedWidget {
|
||||
}
|
||||
|
||||
EdgeInsets _margin(GlobalKey key) {
|
||||
final Widget widget = key.currentContext.widget;
|
||||
final Widget widget = key.currentContext!.widget;
|
||||
final EdgeInsets margin =
|
||||
(widget is Container) ? widget.margin : EdgeInsets.zero;
|
||||
return margin ?? EdgeInsets.zero;
|
||||
|
||||
@@ -211,9 +211,9 @@ class SlidingUpPanel extends StatefulWidget {
|
||||
|
||||
class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProviderStateMixin{
|
||||
|
||||
AnimationController _ac;
|
||||
late AnimationController _ac;
|
||||
|
||||
ScrollController _sc;
|
||||
late ScrollController _sc;
|
||||
bool _scrollingEnabled = false;
|
||||
VelocityTracker _vt = VelocityTracker.withKind(PointerDeviceKind.touch);
|
||||
|
||||
@@ -390,7 +390,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
// and a listener if panelBuilder is used.
|
||||
// this is because the listener is designed only for use with linking the scrolling of
|
||||
// panels and using it for panels that don't want to linked scrolling yields odd results
|
||||
Widget _gestureHandler({Widget child}){
|
||||
Widget _gestureHandler({Widget? child}){
|
||||
if (!widget.isDraggable) return child;
|
||||
|
||||
if (widget.panel != null){
|
||||
@@ -552,14 +552,14 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
|
||||
//animate the panel position to value - must
|
||||
//be between 0.0 and 1.0
|
||||
Future<void> _animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){
|
||||
Future<void> _animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(0.0 <= value && value <= 1.0);
|
||||
return _ac.animateTo(value, duration: duration, curve: curve);
|
||||
}
|
||||
|
||||
//animate the panel position to the snap point
|
||||
//REQUIRES that widget.snapPoint != null
|
||||
Future<void> _animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){
|
||||
Future<void> _animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(widget.snapPoint != null);
|
||||
return _ac.animateTo(widget.snapPoint, duration: duration, curve: curve);
|
||||
}
|
||||
@@ -602,7 +602,7 @@ class _SlidingUpPanelState extends State<SlidingUpPanel> with SingleTickerProvid
|
||||
|
||||
|
||||
class PanelController{
|
||||
_SlidingUpPanelState _panelState;
|
||||
late _SlidingUpPanelState _panelState;
|
||||
|
||||
void _addState(_SlidingUpPanelState panelState){
|
||||
this._panelState = panelState;
|
||||
@@ -644,7 +644,7 @@ class PanelController{
|
||||
/// where 0.0 is fully collapsed and 1.0 is completely open.
|
||||
/// (optional) duration specifies the time for the animation to complete
|
||||
/// (optional) curve specifies the easing behavior of the animation.
|
||||
Future<void> animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear}){
|
||||
Future<void> animatePanelToPosition(double value, {Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
assert(0.0 <= value && value <= 1.0);
|
||||
return _panelState._animatePanelToPosition(value, duration: duration, curve: curve);
|
||||
@@ -654,7 +654,7 @@ class PanelController{
|
||||
/// Requires that the SlidingUpPanel snapPoint property is not null
|
||||
/// (optional) duration specifies the time for the animation to complete
|
||||
/// (optional) curve specifies the easing behavior of the animation.
|
||||
Future<void> animatePanelToSnapPoint({Duration duration, Curve curve = Curves.linear}){
|
||||
Future<void> animatePanelToSnapPoint({Duration? duration, Curve curve = Curves.linear}){
|
||||
assert(isAttached, "PanelController must be attached to a SlidingUpPanel");
|
||||
assert(_panelState.widget.snapPoint != null, "SlidingUpPanel snapPoint property must not be null");
|
||||
return _panelState._animatePanelToSnapPoint(duration: duration, curve: curve);
|
||||
|
||||
Reference in New Issue
Block a user