body method
Implementation
Widget body(BuildContext context) {
final deleteIconImage = Icon(
CupertinoIcons.delete_left,
color: widget.deleteIconColor,
);
final enterIconImage = Icon(
CupertinoIcons.arrow_right_to_line,
color: widget.deleteIconColor,
);
return MeasureSize(
onChange: (size) {
calculateAspectRatio();
},
child: Container(
key: _gridViewKey,
padding: const EdgeInsets.only(left: 40, right: 40, bottom: 30),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
SizedBox(
height: 20,
child: Padding(
padding: const EdgeInsets.fromLTRB(30, 0, 30, 0),
child: ListView(
controller: listController,
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
shrinkWrap: true,
// physics: const NeverScrollableScrollPhysics(),
children: List.generate(pin.length, (index) {
const size = 10.0;
if (index == pin.length - 1) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
child: AnimatedContainer(
width: animate ? size : size + 10,
height: !animate ? size : size + 10,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.filledIndicatorColor,
),
),
);
}
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 8, 0),
child: Container(
width: size,
height: size,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.filledIndicatorColor,
),
),
);
}),
),
),
),
const Spacer(flex: 1),
Flexible(
flex: 26,
child: Container(
child: _aspectRatio > 0
? GridView.count(
shrinkWrap: true,
crossAxisCount: 3,
childAspectRatio: _aspectRatio + 0.18,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(
12,
(index) {
const double marginRight = 15;
const double marginLeft = 15;
const double marginBottom = 4;
if (index == 9) {
return Container(
margin: const EdgeInsets.only(
left: marginLeft, right: marginRight),
child: MergeSemantics(
child: Semantics(
label: widget.deleteButtonLabel,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
widget.deleteButtonColor,
side: widget.borderSide,
foregroundColor:
widget.onPressColorAnimation,
shape: const CircleBorder(),
),
onPressed: () => _onRemove(),
child: deleteIconImage,
),
),
),
);
} else if (index == 10) {
index = 0;
} else if (index == 11) {
return Container(
margin: const EdgeInsets.only(
left: marginLeft, right: marginRight),
child: MergeSemantics(
child: Semantics(
label: widget.enterButtonLabel,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor:
widget.deleteButtonColor,
side: widget.borderSide,
foregroundColor:
widget.onPressColorAnimation,
shape: const CircleBorder(),
),
onPressed: () {
widget.onEnter(pin, this);
clear();
},
child: enterIconImage,
),
),
),
);
} else {
index++;
}
return Container(
margin: const EdgeInsets.only(
left: marginLeft,
right: marginRight,
bottom: marginBottom),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: widget.buttonColor,
foregroundColor:
widget.onPressColorAnimation,
side: widget.borderSide,
shape: const CircleBorder(),
),
onPressed: () => _onPressed(index),
child: Text(
'$index',
style: widget.numbersStyle,
),
),
);
},
),
)
: null),
),
widget.centerBottomWidget != null
? Flexible(
flex: 2,
child: Center(child: widget.centerBottomWidget!),
)
: const SizedBox(),
],
),
),
);
}