小编EhC*_*COD的帖子

尝试添加主色时,Flutter ThemeData 主色未从主题更改

我在 LinkedIn Learning 上关注 London App Brewery 的 BMI 计算器应用程序。当尝试将 PrimaryColor 设置为红色时,即使我覆盖了 Primary Color,我的模拟器仍然显示浅蓝色默认 AppBar。这是代码

    import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primaryColor: Colors.red,
      ),
      home: const InputPage(),
    );
  }
}

class InputPage extends StatefulWidget {
  const InputPage({Key? key}) : super(key: key);

  @override
  _InputPageState createState() => _InputPageState();
}

class _InputPageState …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-theme

25
推荐指数
4
解决办法
3万
查看次数

标签 统计

flutter ×1

flutter-theme ×1