Skip to content
Binary file added assets/dart-ui/canvas_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/canvas_line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/canvas_oval.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/canvas_rect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/canvas_rrect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/clip_path.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/clip_rect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/clip_rrect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/path_conic_to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/path_cubic_to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/path_quadratic_to.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/radius_circular.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/radius_elliptical.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/rect_from_center.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/rect_from_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/rect_from_ltrb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/rect_from_ltwh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dart-ui/rect_from_points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/diagram_generator/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ Future<void> main(List<String> args) async {
AnimationStatusValueDiagramStep(controller),
AppBarDiagramStep(controller),
ArcDiagramStep(controller),
BasicShapesStep(controller),
BlendModeDiagramStep(controller),
BottomNavigationBarDiagramStep(controller),
BoxDecorationDiagramStep(controller),
BoxFitDiagramStep(controller),
CardDiagramStep(controller),
CheckboxListTileDiagramStep(controller),
ClipDiagramStep(controller),
ColorsDiagramStep(controller),
ColumnDiagramStep(controller),
ContainerDiagramStep(controller),
Expand Down
2 changes: 2 additions & 0 deletions packages/diagrams/lib/diagrams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export 'src/animation_diagram.dart';
export 'src/animation_status_value.dart';
export 'src/app_bar.dart';
export 'src/arc_diagram.dart';
export 'src/basic_shapes.dart';
export 'src/blend_mode.dart';
export 'src/bottom_navigation_bar.dart';
export 'src/box_decoration.dart';
export 'src/box_fit.dart';
export 'src/card.dart';
export 'src/checkbox_list_tile.dart';
export 'src/clip_diagram.dart';
export 'src/colors.dart';
export 'src/column.dart';
export 'src/container.dart';
Expand Down
61 changes: 6 additions & 55 deletions packages/diagrams/lib/src/arc_diagram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:vector_math/vector_math_64.dart' hide Colors;

import 'diagram_step.dart';
import 'utils.dart';

class Palette {
const Palette({
Expand Down Expand Up @@ -183,29 +184,6 @@ void paintTextArc(
}
}

/// Paints [span] to [canvas] with a given offset and alignment.
void paintSpan(
Canvas canvas,
TextSpan span, {
required Offset offset,
Alignment alignment = Alignment.center,
TextAlign textAlign = TextAlign.center,
}) {
final TextPainter result = TextPainter(
textDirection: TextDirection.ltr,
text: span,
textAlign: textAlign,
);
result.layout();
result.paint(
canvas,
Offset(
offset.dx + (result.width / -2) + (alignment.x * result.width / 2),
offset.dy + (result.height / -2) + (alignment.y * result.height / 2),
),
);
}

void paintArrowHead(
Canvas canvas,
Offset center,
Expand Down Expand Up @@ -238,35 +216,6 @@ void paintArrowHead(
);
}

/// Similar to [paintSpan] but provides a default text style.
void paintLabel(
Canvas canvas,
String label, {
required Offset offset,
FontStyle style = FontStyle.normal,
FontWeight fontWeight = FontWeight.normal,
Color color = Colors.black45,
double fontSize = 14.0,
Alignment alignment = Alignment.center,
TextAlign textAlign = TextAlign.center,
}) {
paintSpan(
canvas,
TextSpan(
text: label,
style: TextStyle(
color: color,
fontWeight: fontWeight,
fontStyle: style,
fontSize: fontSize,
),
),
offset: offset,
alignment: alignment,
textAlign: textAlign,
);
}

class ArcDiagramPainter extends CustomPainter {
const ArcDiagramPainter({
required this.startAngle,
Expand Down Expand Up @@ -397,9 +346,11 @@ class ArcDiagramPainter extends CustomPainter {
'rect',
offset: rect.topLeft - const Offset(0, 4),
alignment: Alignment.topRight,
color: palette.subtitle,
fontSize: 18.0,
fontWeight: FontWeight.bold,
style: TextStyle(
color: palette.subtitle,
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
);

// Draw arrow at sweepAngle
Expand Down
Loading