We produced arrows with this kind of code.
However, space is inevitably generated. How can we place the widget without generating space?
The tip of the arrow inevitably creates a space between it and the body.
class Line extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SizedBox(
width: 200,
height: 100,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Align(
alignment: Alignment.bottomRight,
child: Transform.rotate(
angle: pi / 4,
child: Container(
width: 16,
height: 1,
color: Colors.white,
),
),
),
const Divider(color: Colors.white),
Align(
alignment: Alignment.bottomRight,
child: Transform.rotate(
angle: -pi / 4,
child: Container(
width: 16,
height: 1,
color: Colors.white,
),
),
),
],
),
);
}
}
3
Answers
You can use the
Transform.translate
widget to to move the upper and lower angular lines. Here is the working code to achieve your desired output:https://phpout.com/wp-content/uploads/2023/12/SNPwa.png
I think you should use
CustomPainter
to draw an arrow. To make your task easy I added code below which can help you.We will draw an Arrow using following coordinates:
To draw above image we will create an ArrowPainter using
CustomPainter
Create an ArrowWidget:
Now you can use ArrowWidget anywhere in you code.
Note: I am using width=height to draw arrow. you can change above code as per your requirement. Also do import for required classes.