build method
Describes the part of the user interface represented by this widget.
The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change.
Implementation
@override
Widget build(BuildContext context) {
return Visibility(
visible: isVisible,
child: AnimatedPositioned(
duration: animationsDuration,
bottom: 80 + context.bottomPadding,
right: 0,
left: 0,
child: Container(
height: context.width * .175,
width: context.width,
alignment: Alignment.center,
child: PageView.builder(
controller: gradientsPageController,
itemCount: gradientColors.length,
onPageChanged: onPageChanged,
physics: const BouncingScrollPhysics(),
allowImplicitScrolling: true,
pageSnapping: false,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () => onItemTap(index),
child: Container(
height: context.width * .175,
width: context.width * .175,
margin: const EdgeInsets.all(4),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.centerRight,
colors: gradientColors[index],
),
borderRadius: BorderRadius.all(
Radius.circular(context.width * .175),
),
border: Border.all(
color: Colors.white,
),
),
child: Center(
child: AnimatedSwitcher(
duration: animationsDuration,
child: index == selectedGradientIndex
? Icon(
CupertinoIcons.checkmark_alt,
color: selectedGradientIndex == 0
? Colors.white
: gradientColors[selectedGradientIndex]
.last
.computeLuminance() >
0.5
? Colors.black
: Colors.white,
)
: const SizedBox(),
),
),
),
);
},
),
),
),
);
}