Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
344 views
in Technique[技术] by (71.8m points)

flutter - Widget outside of parents Border(Radius)

I am trying to get a line indicating progress to work. I use the LinearProgressIndicator-Widget. My structure looks roughly like this:

 Container( // outer Container
    width: widgetWidth,
    decoration: BoxDecoration(
        color: lectionColor, 
        borderRadius: BorderRadius.circular(10)),
    child: Column(children[
        // multiple other children 
        Conatiner( // inner Container
            height: deviceHeight * 0.005,
            width: widgetWidth,
            child: LinearProgressIndicator(
                value: percentageOfMediaAlreadyDone,
                backgroundColor: Colors.transparent,
                valueColor: AlwaysStoppedAnimation<Color>(progressColor),
                ),
            )
        )
    ])

The problem is, that the inner Container & LinearProgressIndicator leave the BorderRadius of the outer Container (as seen in this image). Problem The progressBar should be as width as the outer Container, but only be shown, where the outer Container is (so only on the blue Container, not on the white background).

Even if I add a BorderRadius.only to the inner Container, that does not fix the problem, since 1) its not high enough & 2) the LinearProgressIndicator disregards this borderRadius again (as seen in thi image). Failed try to fix

My current workaround is to reduce the width of the inner Container to not conflict with the BorderRadius of the outer Container, but I am not content with that version.

[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.19041.746], locale en-DE)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)

question from:https://stackoverflow.com/questions/66062808/widget-outside-of-parents-borderradius

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can try to wrap the outer Container with ClipRRect

ClipRRect(
  borderRadius: BorderRadius.circular(10),
  child: Container(
   ...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...