[0.1.0]
This commit is contained in:
@@ -55,17 +55,17 @@ class GradientOutlineInputBorder extends InputBorder {
|
||||
double gapPercentage = 0.0,
|
||||
TextDirection? textDirection,
|
||||
}) {
|
||||
final paint = _getPaint(rect);
|
||||
final outer = borderRadius.toRRect(rect);
|
||||
final center = outer.deflate(borderSide.width / 2.0);
|
||||
final Paint paint = _getPaint(rect);
|
||||
final RRect outer = borderRadius.toRRect(rect);
|
||||
final RRect center = outer.deflate(borderSide.width / 2.0);
|
||||
if (gapStart == null || gapExtent <= 0.0 || gapPercentage == 0.0) {
|
||||
canvas.drawRRect(center, paint);
|
||||
} else {
|
||||
final extent =
|
||||
final double extent =
|
||||
lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage)!;
|
||||
switch (textDirection!) {
|
||||
case TextDirection.rtl:
|
||||
final path = _gapBorderPath(
|
||||
final Path path = _gapBorderPath(
|
||||
canvas,
|
||||
center,
|
||||
math.max(0, gapStart + gapPadding - extent),
|
||||
@@ -75,7 +75,7 @@ class GradientOutlineInputBorder extends InputBorder {
|
||||
break;
|
||||
|
||||
case TextDirection.ltr:
|
||||
final path = _gapBorderPath(
|
||||
final Path path = _gapBorderPath(
|
||||
canvas,
|
||||
center,
|
||||
math.max(0, gapStart - gapPadding),
|
||||
@@ -112,39 +112,39 @@ class GradientOutlineInputBorder extends InputBorder {
|
||||
// When the corner radii on any side add up to be greater than the
|
||||
// given height, each radius has to be scaled to not exceed the
|
||||
// size of the width/height of the RRect.
|
||||
final scaledRRect = center.scaleRadii();
|
||||
final RRect scaledRRect = center.scaleRadii();
|
||||
|
||||
final tlCorner = Rect.fromLTWH(
|
||||
final Rect tlCorner = Rect.fromLTWH(
|
||||
scaledRRect.left,
|
||||
scaledRRect.top,
|
||||
scaledRRect.tlRadiusX * 2.0,
|
||||
scaledRRect.tlRadiusY * 2.0,
|
||||
);
|
||||
final trCorner = Rect.fromLTWH(
|
||||
final Rect trCorner = Rect.fromLTWH(
|
||||
scaledRRect.right - scaledRRect.trRadiusX * 2.0,
|
||||
scaledRRect.top,
|
||||
scaledRRect.trRadiusX * 2.0,
|
||||
scaledRRect.trRadiusY * 2.0,
|
||||
);
|
||||
final brCorner = Rect.fromLTWH(
|
||||
final Rect brCorner = Rect.fromLTWH(
|
||||
scaledRRect.right - scaledRRect.brRadiusX * 2.0,
|
||||
scaledRRect.bottom - scaledRRect.brRadiusY * 2.0,
|
||||
scaledRRect.brRadiusX * 2.0,
|
||||
scaledRRect.brRadiusY * 2.0,
|
||||
);
|
||||
final blCorner = Rect.fromLTWH(
|
||||
final Rect blCorner = Rect.fromLTWH(
|
||||
scaledRRect.left,
|
||||
scaledRRect.bottom - scaledRRect.blRadiusY * 2.0,
|
||||
scaledRRect.blRadiusX * 2.0,
|
||||
scaledRRect.blRadiusX * 2.0,
|
||||
);
|
||||
|
||||
const cornerArcSweep = math.pi / 2.0;
|
||||
final tlCornerArcSweep = start < scaledRRect.tlRadiusX
|
||||
const double cornerArcSweep = math.pi / 2.0;
|
||||
final double tlCornerArcSweep = start < scaledRRect.tlRadiusX
|
||||
? math.asin((start / scaledRRect.tlRadiusX).clamp(-1.0, 1.0))
|
||||
: math.pi / 2.0;
|
||||
|
||||
final path = Path()
|
||||
final Path path = Path()
|
||||
..addArc(tlCorner, math.pi, tlCornerArcSweep)
|
||||
..moveTo(scaledRRect.left + scaledRRect.tlRadiusX, scaledRRect.top);
|
||||
|
||||
@@ -152,16 +152,16 @@ class GradientOutlineInputBorder extends InputBorder {
|
||||
path.lineTo(scaledRRect.left + start, scaledRRect.top);
|
||||
}
|
||||
|
||||
const trCornerArcStart = (3 * math.pi) / 2.0;
|
||||
const trCornerArcSweep = cornerArcSweep;
|
||||
const double trCornerArcStart = (3 * math.pi) / 2.0;
|
||||
const double trCornerArcSweep = cornerArcSweep;
|
||||
if (start + extent < scaledRRect.width - scaledRRect.trRadiusX) {
|
||||
path
|
||||
..relativeMoveTo(extent, 0)
|
||||
..lineTo(scaledRRect.right - scaledRRect.trRadiusX, scaledRRect.top)
|
||||
..addArc(trCorner, trCornerArcStart, trCornerArcSweep);
|
||||
} else if (start + extent < scaledRRect.width) {
|
||||
final dx = scaledRRect.width - (start + extent);
|
||||
final sweep = math.acos(dx / scaledRRect.trRadiusX);
|
||||
final double dx = scaledRRect.width - (start + extent);
|
||||
final double sweep = math.acos(dx / scaledRRect.trRadiusX);
|
||||
path.addArc(trCorner, trCornerArcStart + sweep, trCornerArcSweep - sweep);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientUnderlineInputBorder extends InputBorder {
|
||||
@@ -52,7 +49,7 @@ class GradientUnderlineInputBorder extends InputBorder {
|
||||
double gapPercentage = 0.0,
|
||||
TextDirection? textDirection,
|
||||
}) {
|
||||
final paint = _getPaint(rect);
|
||||
final Paint paint = _getPaint(rect);
|
||||
Rect underlineRect = Rect.fromLTWH(rect.left, rect.height - width, rect.width, width);
|
||||
canvas.drawRect(underlineRect, paint);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user