Instantly share code, notes, and snippets.

Embed
What would you like to do?
class _PriceTabState extends State<PriceTab> with TickerProviderStateMixin {
final List<FlightStop> _flightStops = [
FlightStop("JFK", "ORY", "JUN 05", "6h 25m", "\$851", "9:26 am - 3:43 pm"),
FlightStop("MRG", "FTB", "JUN 20", "6h 25m", "\$532", "9:26 am - 3:43 pm"),
FlightStop("ERT", "TVS", "JUN 20", "6h 25m", "\$718", "9:26 am - 3:43 pm"),
FlightStop("KKR", "RTY", "JUN 20", "6h 25m", "\$663", "9:26 am - 3:43 pm"),
];
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: <Widget>[_buildPlane()]
..addAll(_flightStops.map(_buildStopCard))
..addAll(_flightStops.map(_mapFlightStopToDot)),
),
);
}
Widget _buildStopCard(FlightStop stop) {
int index = _flightStops.indexOf(stop);
double topMargin = _dotPositions[index].value -
0.5 * (FlightStopCard.height - AnimatedDot.size);
bool isLeft = index.isOdd;
return Align(
alignment: Alignment.topCenter,
child: Padding(
padding: EdgeInsets.only(top: topMargin),
child: Row(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
isLeft ? Container() : Expanded(child: Container()),
Expanded(
child: FlightStopCard(
flightStop: stop,
isLeft: isLeft,
),
),
!isLeft ? Container() : Expanded(child: Container()),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment