Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created September 3, 2018 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/2d5ab1a818cec54ff7bb5f36274c6abe to your computer and use it in GitHub Desktop.
Save MarcinusX/2d5ab1a818cec54ff7bb5f36274c6abe to your computer and use it in GitHub Desktop.
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