【问题标题】:Flutter : Applying Gradient Background For MaterialApp ClassFlutter:为 MaterialApp 类应用渐变背景
【发布时间】:2020-02-28 04:18:42
【问题描述】:

请帮助我,如何使用 MaterialApp 类将渐变背景应用于整个项目,而不是创建 Container 或 Scaffold 类? 以下是我在 main.dart 的启动代码。

谢谢!

    class App extends StatelessWidget {

    @override
    Widget build(BuildContext context) {
        return MaterialApp(
            debugShowCheckedModeBanner: false,
            title: 'Testing App',
            theme: new ThemeData(
            primaryColor: Color(0xffD67219),
            fontFamily: 'Poppins',
            ),
        home: LoginPage(),
        );
   }
   }

【问题讨论】:

  • 你不能这样做 - 你需要一些Container 来显示你的渐变

标签: flutter dart flutter-layout


【解决方案1】:

MaterialApp 仅提供上述功能。您必须使用Scaffold 来获取渐变色背景。

decoration: new BoxDecoration(
        gradient: LinearGradient(
         colors: [const Color(0xff013852),
    const Color(0xff00283c),
    ],),),

【讨论】:

    猜你喜欢
    • 2018-10-28
    • 2020-08-04
    • 2021-05-28
    • 2020-04-21
    • 1970-01-01
    • 2021-02-27
    • 1970-01-01
    • 1970-01-01
    • 2012-03-31
    相关资源
    最近更新 更多