简体   繁体   English

如何为我的整个 Flutter 应用程序提供线性渐变?

[英]How can I give Linear gradient to my entire flutter app?

Here's the code, The problem is that there is a gap of black colour around the rounded corners due to theme data being black.这是代码,问题是由于主题数据为黑色,圆角周围存在黑色间隙。 I can't fill it with gradient present in the above container.我无法用上述容器中的渐变填充它。 image has been attached.图片已附上。 any solution?任何解决方案?

 class _TrackListState extends State<TrackList> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Expanded(
              child: Container(
                height: double.infinity,
                //child: Text('hello'),
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                      colors: [Color(0xFF04DCB6), Color(0xFF6DE079)]),
                ),
                child: Column(
                  children: <Widget>[],
                ),
              ),
            ),
            Expanded(
              flex: 3,
              child: Container(
                //padding: EdgeInsets.symmetric(horizontal: 20),
                foregroundDecoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(30),
                    topRight: Radius.circular(30),
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

The image where I am having the problem我遇到问题的图像

I tested it on DartPad.我在 DartPad 上测试过。 Give it a try.试一试。 Using stack, you can fill the background and draw on top of it.使用堆栈,您可以填充背景并在其上绘制。

      @override
      Widget build(BuildContext context) {
        return Stack(
          fit: StackFit.expand,
          children: <Widget>[
            Container(
              decoration: BoxDecoration(
                gradient:
                    LinearGradient(colors: [Color(0xFF04DCB6), Color(0xFF6DE079)]),
              ),
            ),
            Positioned.fill(
              top: 80,
              child: Container(
                foregroundDecoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(30),
                    topRight: Radius.circular(30),
                  ),
                ),
              ),
            ),
          ],
        );
      }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 flutter 中赋予复选框渐变? - How to give checkbox gradient in flutter? 如何授予我的Android应用根权限? - How can I give root permission to my Android app? 如何修复我的 flutter 应用程序与我的华为的连接? - How can i fix the connection of my flutter app to my huawei? 如何在我的 Flutter 应用程序中添加启动画面? - How can I add splash screen I my flutter app? 当我的整个应用程序都在后台时,我如何在服务中知道 - How can i know in my service when my entire app is in the background 我如何在我的 flutter 应用程序中使用第二个 firebase 项目? - How can i user second firebase project in my flutter app? 如何从其他应用程序启动我的 Flutter 应用程序 - How can I Launch My Flutter App from other Apps 如何在我的 flutter 应用程序中使汉堡图标更大 - how can i make the burger icon bigger in my flutter app 如何在颤动中为底部导航栏图标提供渐变 - How to give gradient for Bottom navigation bar icons in flutter 在尝试访问文件系统之前,如何确保我的Android 6 Cordova应用程序提示用户授予权限? - How can I ensure that my Android 6 Cordova app prompts the user to give permission before attempting to access the filesystem?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM