已弃用的背景和onSurface的新方法是什么

问题描述 投票:0回答:1
import 'package:expensetracker/screens/home/views/home_screen.dart';
import 'package:flutter/material.dart';

class MyAppView extends StatelessWidget {
  const MyAppView({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Expense Tracker',
      theme: ThemeData(
        colorScheme: ColorScheme.light(
            background: Colors.grey.shade100,
            onBackground: Colors.black,
            primary: const Color(0xFF00B2E7),
            secondary: const Color(0xFFE064F7),
            tertiary: const Color(0xFFFF8D6C),
            outline: Colors.grey),
      ),
      home: const HomeScreen(),
    );
  }
}

我只是想要相同的问题结果,遗憾的是背景已被废弃。

flutter deprecated
1个回答
0
投票

background
应替换为
surface
,并且
onBackground
应替换为
onSurface
。 阅读有关新配色方案迁移指南的更多信息此处

© www.soinside.com 2019 - 2024. All rights reserved.