Skip to content

StarBorder does not lerp to Oval #108707

Closed

Description

@bernaferrari

The new StarBorder has a genius 2-3 step lerp for most shapes, except Circle, where it works well except when eccentricity != 0. I think it was forgotten in the implementation, as Oval is only a few weeks old. I propose adding the 2-way lerp to circle, so oval works. cc @gspencergoog

Related: in the upcoming BoderSide.only PR, which may or may not be accepted, Star -> Circle is the only lerp that doesn't work, as it draws a path all the time. The other shapes draw a path until 50%, then their shape until 100%, so lerp is good (not great, might need a few fixes). I see two potential solutions:

  • Add 2 step lerp for Oval (and eccentricity != 0).
  • Add 2 step lerp for all circles.

If you fix oval only, in a hypothetical future, we might need to do if (multiBorder) 2-step lerp for circle, which is also fine. Just telling you the plan.

Screen.Recording.2022-07-31.at.17.45.57.mov

Simple sample:

StarBorder(
    side: BorderSide(color: Colors.yellow.withOpacity(0.5), width: 10),
).lerpTo(RoundedRectangleBorder(side: BorderSide(color: Colors.red.withOpacity(0.5), width: 10), 0.5)

Activity

  1. maheshj01 commented on Aug 1, 2022

    @maheshj01
    Member

    Hi @bernaferrari, Thanks for filing the issue. Can you please share a code sample or confirm if this code sample is right?

    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(
            title: 'Flutter Demo',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: Material(
              child: SizedBox(
                height: 100,
                width: 100,
                child: Container(
                  alignment: Alignment.center,
                  decoration: ShapeDecoration(
                      color: Colors.white,
                      shape: StarBorder(
                        side: BorderSide(
                            color: Colors.yellow.withOpacity(0.5), width: 10),
                      ).lerpTo(
                          RoundedRectangleBorder(
                              side: BorderSide(
                                  color: Colors.red.withOpacity(0.5), width: 10)),
                          0.5)!),
                ),
              ),
            ));
      }
    }
    
    [✓] Flutter (Channel master, 3.1.0-0.0.pre.2009, on macOS 12.4 21F79 darwin-arm, locale en-IN)
        • Flutter version 3.1.0-0.0.pre.2009 on channel master at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9d96c7b8be (8 hours ago), 2022-08-01 00:39:06 -0400
        • Engine revision cf0db3e546
        • Dart version 2.19.0 (build 2.19.0-49.0.dev)
        • DevTools version 2.16.0
    
  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 1, 2022
  3. bernaferrari commented on Aug 1, 2022

    @bernaferrari
    ContributorAuthor

    I knew by the time I went to answer this, there would be a PR already. Nice work @gspencergoog! lol

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 1, 2022
  5. bernaferrari commented on Aug 1, 2022

    @bernaferrari
    ContributorAuthor

    Yes, seems like a great sample @maheshmnj. Thanks!

  6. added
    r: fixedIssue is closed as already fixed in a newer version
    and removed
    in triagePresently being triaged by the triage team
    on Aug 2, 2022
  7. github-actions commented on Aug 16, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions