flutter - 如何在我的 Flutter 应用程序中添加渐变背景?

标签 flutter user-interface dart background flutter-layout

我想在我的 flutter 应用程序背景中使用 Liner 渐变颜色样式,如何在我的 flutter 应用程序中实现它?

最佳答案

您可以简单地在 BoxDecoration 中使用正确的参数

https://api.flutter.dev/flutter/painting/LinearGradient-class.html

Container(
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topLeft,
          end:
              Alignment(0.8, 0.0), // 10% of the width, so there are ten blinds.
          colors: [
            const Color(0xffee0000),
            const Color(0xffeeee00)
          ], // red to yellow
          tileMode: TileMode.repeated, // repeats the gradient over the canvas
        ),
      ),
    );

关于flutter - 如何在我的 Flutter 应用程序中添加渐变背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64861076/

相关文章:

flutter - 我收到错误消息:在此设置小部件上方找不到正确的Provider <User>(已修复)

dart - 一个项目中有多个 SharedPreferences

flutter : Unhandled Exception: setState() called after dispose() occurs when refreshing the page

ios - 手动编辑 iOS Storyboard文件在技术上可以吗?

dart - 使用 flutter 将在线图像 uri 转换为 base64

flutter - 如何从 flutter 中的 isolate 调用平台代码?

objective-c - 创建 NSTextField "label"的示例代码?

css - 如何仅在鼠标悬停时连续显示按钮?

asynchronous - 我怎样才能正确地从使用 Futures/async/await 的流中产生?

flutter - 使用 map 而不是 for 语句使类模型中的列表返回零