Skip to content

Container clipBehavior not working #85268

Description

@steeling

On flutter dart pad:

import 'package:flutter/material.dart';

final Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color:Colors.orange,
      child: Container(
              height: 100,
              width: 100,
              clipBehavior: Clip.antiAlias,
              // margin: EdgeInsets.symmetric(horizontal: 20),
              padding: EdgeInsets.symmetric(vertical: 12),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: Colors.blue,
                borderRadius: BorderRadius.circular(20),
              ),
        ),
    );
  }
}

Anti alias clip behavior is not working

Activity

  1. darshankawar commented on Jun 25, 2021

    @darshankawar
    Member

    @steeling
    What's the expected behavior are you looking for ?
    Can you provide flutter doctor -v and also see if it works for you on mobile ?

    Thanks.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 25, 2021
  3. steeling commented on Jun 25, 2021

    @steeling
    Author

    It's viewable in a dartpad FYI, but yes I see it on mobile as well. Flutter doctor:

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale en-US)
    • Flutter version 2.2.2 at /Users/steeling/dev/flutter
    • Framework revision d79295a (2 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

    [✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
    Install Android Studio from: https://developer.android.com/studio/index.html
    On first launch it will assist you in installing the Android SDK components.
    (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
    If the Android SDK has been installed to a custom location, please use
    flutter config --android-sdk to update to that location.

    [✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.0

    [✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    [!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
    (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

    [✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

    [✓] Connected device (2 available)
    • iPhone 12 mini (mobile) • 2297B16A-10FC-4973-A362-530380896D7E • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114

    ! Doctor found issues in 2 categories.

    I'd expect it to clip properly to the rounded border

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 25, 2021
  5. darshankawar commented on Jun 28, 2021

    @darshankawar
    Member

    @steeling
    If you use border: Border.all(), inside BoxDecoration, it gives below:

    Screenshot 2021-06-28 at 11 35 28 AM

    Does this help ?

  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 28, 2021
  7. steeling commented on Jun 29, 2021

    @steeling
    Author

    I'd expect there to be no orange portion in the image

  8. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 29, 2021
  9. darshankawar commented on Jun 30, 2021

    @darshankawar
    Member

    Thanks. It seems the directly using the clipBehavior: Clip.antiAlias inside Container doesn't clip the edges, as below:

    Screenshot 2021-06-30 at 11 36 55 AM

    But using the same code as provided above, if we use Card widget instead of parent Container and use shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)), then it somewhat clips the orange edges.

    Screenshot 2021-06-30 at 11 38 48 AM

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.4 19E2269 darwin-x64,
        locale en-GB)
        • Flutter version 2.2.2 at /Users/dhs/documents/fluttersdk/flutter
        • Framework revision d79295af24 (11 days ago), 2021-06-11 08:56:01 -0700
        • Engine revision 91c9fc8fe0
        • Dart version 2.13.3
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.3, Build version 12C33
        • CocoaPods version 1.10.1
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.56.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (4 available)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 91.0.4472.106
    
    • No issues found!
    
    
    
    
  10. darshankawar commented on Jun 30, 2021

    @darshankawar
    Member
  11. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jun 30, 2021
  12. MatrixDev commented on Jan 6, 2025

    @MatrixDev

    Just want to add that this bug is still present in the latest version, just so this issue is not auto-closed.

  13. codelovercc commented on Feb 7, 2026

    @codelovercc

    ?? any update?

  14. flutter-triage-bot commented on Feb 7, 2026

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

  15. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Feb 11, 2026
  16. added a commit that references this issue on Apr 3, 2026
    882aa06
  17. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
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

    P2Important issues not at the top of the work listfound in release: 2.2Found to occur in 2.2has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions