How to draw a Horizontal line in Flutter?

This Article is posted by seven.srikanth at 27-12-2018 14:15:50

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.
If you looking for a decorative horizontal line as shown below ( ---------- or ----------- ), then here is the link for that article. 
How to draw a Decorative Horizontal line in Flutter? - https://fluttercentral.com/Articles/Post/1148
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.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: CustomPaint(painter: Drawhorizontalline()),
),
);
}
}
class Drawhorizontalline extends CustomPainter {
Paint _paint;
Drawhorizontalline() {
_paint = Paint()
..color = Colors.white
..strokeWidth = 1
..strokeCap = StrokeCap.round;
}
@override
void paint(Canvas canvas, Size size) {
canvas.drawLine(Offset(-90.0, 0.0), Offset(90.0, 0.0), _paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return 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.



Recent Articles


How to deploy flutter web site on GitHub using peanut

Posted by nikhilchaudhary12155 on 13 Oct 2019 Article


AnimatedPositioned Widget Example in Flutter

Posted by seven.srikanth on 10 Oct 2019 Article


Flutter Open-Source and directory lists

Posted by nishantkotatech on 09 Oct 2019 Article


Flutter Travelling Couple Leading Page - Flutter Web Series 3

Posted by nikhilchaudhary12155 on 05 Oct 2019 Article



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