by @kodeazy
flutter how to add an Horizontal line?
In this blog we will discuss on how to add a horizontal line in flutter.
To draw a horizontal line in flutter we use Divider widget
Below is an example syntax of drawing an horizontal line in flutter.
Divider(
color: Colors.black,
thickness: 1,
)
Below is an example program of drawing a line below two containers.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Divider Example'),),
backgroundColor: Colors.amber.shade100,
body: Column(
children : [Row(
children:<Widget> [
Expanded(
child: Container(
height: 100,
color: Colors.white,
margin: EdgeInsets.all(25),
),
),
Expanded(
child: Container(
height: 100,
color: Colors.red,
margin: EdgeInsets.all(25),
),
)
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Divider(
color: Colors.black,
thickness: 1,
),
)
]),
),
);
}
}