Based on a transformation optics method, a flat compact dual-polarized Luneburg lens antenna is proposed and implemented using the printed-circuit-board-stacked gradient-index metamaterials for beamscanning and multibeam applications at X-hands. The transformed material properties of the planar Luneburg lens are designed with 17-layered permittivity distribution of polynomials. Each layer is discretized into 41 x 41 pixels made of broadband and less polarization-dependent unit cells responsible for desired index distributions. The effects of transformation, approximation, and discretization on the lens performance are analyzed comprehensively. Also, to validate the implementation method, a flat Luneburg lens with a thickness of 14.1 mm, a focal length of 28 mm, and an aperture size of 98.9 x 98.9 mm(2) is designed and tested. A stacked aperture-coupled patch antenna operating at 10 GHz is applied as a feeder. The measured results show that the proposed antenna can operate over a bandwidth of similar to 20% with an antenna efficiency of 32%, a crass-polarization level of <-17.1 dB, as well as the maximum gain of 15.9/16.35 dBi and a scanning angle of +/- 32 degrees/+/- 35 degrees for two orthogonal polarizations, respectively. The presented flat Luneburg lens antenna featuring broad bandwidth, high gain, wide scanning angle, and easy fabrication has a high potential in 5G wireless communication, imaging, and remote sensing applications.