How to draw a Horizontal line in Flutter?

This Article is posted by seven.srikanth at 12/27/2018 2:15:50 PM

Hello Guys, In this article, I'm going to show you how to draw a horizontal line in Flutter. See below images on how the output is going to look. Nothing fancy. ![](https://fluttercentral.com/Uploads/bc18e822-11bb-4509-b30c-c4d85d006d3b.PNGwidth="50%height="auto]( If you looking for a decorative horizontal line as shown below (font-size: 1rem; color: rgb(33, 37, 41); white-space: pre-wrap; background-color: rgb(233, 236, 239);]( font-size: 1rem; color: rgb(33, 37, 41); white-space: pre-wrap; background-color: rgb(233, 236, 239);](---------- or ----------- font-size: 1rem;](), then here is the link for that article. How to draw a Decorative Horizontal line in Flutter? - [https://fluttercentral.com/Articles/Post/1148font-size: 1rem;](https://fluttercentral.com/Articles/Post/1148) ![](https://fluttercentral.com/Uploads/f173b2fa-c5c7-4ec1-9aa7-b53681e54955.PNG]( font-size: 1rem;]( Here is the full code for this example. All you need is to copy paste this code to your main.dart file in newly created flutter project. color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](color: #569cd6;](import color: #ce9178;]('package:flutter/material.dart'; color: #569cd6;](void main() { runApp(MyApp());} color: #569cd6;](class MyApp color: #569cd6;](extends StatelessWidget { color: #569cd6;](@override Widget build(BuildContext context) { color: #569cd6;](return Center( child: Container( child: CustomPaint(painter: Drawhorizontalline()), ), ); }} color: #569cd6;](class Drawhorizontalline color: #569cd6;](extends CustomPainter { Paint _paint; Drawhorizontalline() { _paint = Paint() ..color = Colors.white ..strokeWidth = color: #b5cea8;](1 ..strokeCap = StrokeCap.round; } color: #569cd6;](@override color: #569cd6;](void paint(Canvas canvas, Size size) { canvas.drawLine(Offset(-color: #b5cea8;](90.0, color: #b5cea8;](0.0), Offset(color: #b5cea8;](90.0, color: #b5cea8;](0.0), _paint); } color: #569cd6;](@override color: #569cd6;](bool shouldRepaint(CustomPainter oldDelegate) { color: #569cd6;](return color: #569cd6;](false; }} Actually, by changing a few things. You can draw vertical and cross lines too using this class. Hope this is useful to you. Thanks,Srikanth

Tags: How to draw a Horizontal line in Flutter?



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.




© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com