Stunning Ticket Widget For Flutter 🍿

Abdul Rehman
3 min readAug 29, 2022

Add beautiful Ticket UI in your flutter app.

In this article, we will create a widget that looks like ticket. We can use that widget anywhere in our app to make our app look sleek. We will use CustomPainter to draw ticket UI widget.

⚙️ Let’s Create A Base Widget

We will first create a TicketUi widget, which we will transform into a ticket like widget.

Later we will add a CustomPainter to our above widget. The CustomPainter will transform the widget into a beautiful ticket UI.

🎨 Implement Custom Painter

Let’s create a root CustomPainter class, and name it TicketPainter. We will pass background color and border color in the constructor of TicketPainter class.

We have also defined some variables for class. This will be used to draw the ticket UI.

Draw Ticket Widget ✍️

Now we will define the size of the ticket cutout and radius. You can change this according to your needs. We will also define the size of the dashed line.

Above we have defined the X, Y coordinates of different UI components. This X, Y coordinates will be used to draw the path of cutout and dashed line in your widget.

Now we will implement methods to draw cutout and corner arc. 🖌

Now the final step is to add the path to draw out ticket UI. 🛣

Photo by Irene Strong on Unsplash

🏁 Finally, Add Custom Painter To Widget

The last step is to add the CustomPainter to our initialTicketUi widget.

🤩 Voilà! we have created an awesome ticket UI.

Final ticket UI with some custom UI. You can create your own UI according to your needs.🥳

Thank you, and I hope this article helped you in some way. If you like the post, please support the article by sharing it. Have a nice day!👋

I am an mobile enthusiast 📱. My expertise is in Flutter and Android development, with more than 5 years of experience in the industry.

I would love to write technical blogs for you. Writing blogs and helping people is what I crave for 😊 .You can contact me at my email(abdulrehman0796@gmail.com) for any collaboration 👋

🔗 LinkedIn: https://www.linkedin.com/in/abdul-rehman-khilji/

--

--

Abdul Rehman

Mobile developer in love with Flutter and Android ♥️