我还是个初来乍到的人,所以我决定学习一个教程,教我如何使用Flight制作一个Spotify克隆版.他指定了一个定制的黑色主题,当他运行代码时,它确实是一个黑色主题,但当我运行它时,它仍然是白色的.我最初以为我在某个地方打了一个字,所以我复制了他的代码,但这并没有改变任何事情.

I get this result The result I get

This is the result I want to get The expected result

我的main.dart文件


import 'package:flutter/material.dart';

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

class Spotify extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Spotify UI',
      debugShowCheckedModeBanner: false,
      darkTheme: ThemeData(
        brightness: Brightness.dark,
        appBarTheme: const AppBarTheme(backgroundColor: Colors.black),
        scaffoldBackgroundColor: const Color(0xFF121212),
        backgroundColor: const Color(0xFF121212),
        primaryColor: Colors.black,
        accentColor: const Color(0xFF1DB954),
        iconTheme: const IconThemeData().copyWith(color: Colors.black),
        fontFamily: 'Montserrat',
        textTheme: TextTheme(
          headline2: const TextStyle(
            color: Colors.white,
            fontSize: 32.0,
            fontWeight: FontWeight.bold,
          ),
          headline4: TextStyle(
            fontSize: 12.0,
            color: Colors.grey[300],
            fontWeight: FontWeight.w500,
            letterSpacing: 2.0,
          ),
          bodyText1: TextStyle(
            color: Colors.grey[300],
            fontSize: 14.0,
            fontWeight: FontWeight.w600,
            letterSpacing: 1.0,
          ),
          bodyText2: TextStyle(
            color: Colors.grey[300],
            letterSpacing: 1.0,
          ),
        ),
      ),
      home: Shell(),
    );
  }
}

class Shell extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: Row(
              children: [
                Container(
                  height: double.infinity,
                  width: 280.0,
                  color: Colors.green,
                ),
                // PlaylistScreen
              ],
            ),
          ),
          Container(
            height: 84.0,
            width: double.infinity,
            color: Colors.blue,
          ),
        ],
      ),
    );
  }
}

推荐答案

Scaffold()人设 backgroundColor: Colors.black,

Flutter相关问答推荐

ShaderMask上的文本渐变问题

使用Flutter 提供程序包加载状态应用程序时,在自定义按钮中显示CircularProgressIndicator

如何在不使用NULL-check(!)的情况下缩小`FutureBuilder.Builder()`内部的`Snaphot`范围

如何在WidgetRef引用外部的函数中使用Riverpod刷新数据

我有一个问题:类型';()=>;Null';不是类型转换中类型';(Int)=>;void';的子类型

如何实现Flutter 梳理机图像的小量移动

如何删除使用isscllable时出现的左边距?

为什么PUT方法没有发出任何响应?

如何使排内 children 的身高与其他排内 children 的身高相适应?

运行任何 flutter 命令都会显示无法安装 <版本>

点击按钮后重新启动定时器

使用Flutter项目设置Firebase遇到困难?这些解决方案或许能帮到你!

使用 Play Integrity API 时,Firebase 电话身份验证问题缺少客户端标识符错误

ListView 后台可见

为什么 ref.watch(otherProvider.stream) 在 Riverpod 2.x 中被弃用并且将在 3.x 中被删除?

当我使用 Confetti Widget 时,Flutter Android 和 IOS 应用程序崩溃

使用 onPressed 切换到另一个屏幕无法正常工作

Flutter:滚动一个ListWheelScrollView,无法获取选中项的状态

在 Flutter Bloc 中具有称为 status 的属性的一种状态或不同的状态,哪个更可取?

如何做到这一点,当我们在 textified 中输入 ab 然后将 applebanana 显示为一个单词?飘飘然