Flutter入门: ThemeData详解

Auth:𝕃𝕖𝕠𝕏       Date:2024/04/15       Cat:编程       Word:共13427字

  1. 前言
  2. 属性
    1. 属性一览
    2. fontFamily: 应用程序的默认字体样式
    3. actionIconTheme: 动作图标主题
      1. 实现
      2. 示例
    4. appBarTheme: 自定义 AppBar 部件的主题
      1. 实现
      2. 示例
    5. applyElevationOverlayColor: 是否应用elevation覆盖颜色
      1. 实现
      2. 示例
    6. badgeTheme: 自定义 Badge 部件的主题
      1. 实现
      2. 示例
    7. bannerTheme: 自定义 MaterialBanner 部件的主题
      1. 实现
      2. 示例
    8. bottomAppBarTheme: 自定义 BottomAppBar 部件的主题
      1. 实现
      2. 示例
    9. bottomSheetTheme: 自定义 BottomSheet 部件的主题
      1. 实现
      2. 示例
    10. brightness: 应用程序的亮度模式
      1. 实现
      2. 示例
    11. buttonBarTheme: 自定义 ButtonBar 部件的主题
      1. 实现
      2. 示例
    12. cardTheme: 自定义 Card 部件的主题
      1. 实现
      2. 示例
    13. checkboxTheme: 自定义 Checkbox 部件的主题
      1. 实现
      2. 示例
    14. chipTheme: 自定义 Chip 部件的主题
      1. 实现
      2. 示例
    15. colorScheme: 快速创建应用程序的颜色主题
      1. 实现
      2. 示例
    16. cupertinoOverrideTheme: 覆盖Cupertino风格主题
      1. 实现
      2. 示例
    17. dataTableTheme: 自定义 DataTable 部件的主题
      1. 实现
      2. 示例
    18. datePickerTheme: 自定义 DatePickerDialog 部件的主题
      1. 实现
      2. 示例
    19. dialogBackgroundColor: Dialog 背景颜色
      1. 实现
      2. 示例
    20. dialogTheme: 自定义 Dialog 主题
      1. 实现
      2. 示例
    21. dividerTheme: 分割线样式
      1. 实现
      2. 示例
    22. drawerTheme: 自定义 Drawer 部件的主题
      1. 实现
      2. 示例
    23. dropdownMenuTheme: 自定义 DropdownMenu 部件的主题
      1. 实现
      2. 示例
    24. elevatedButtonTheme: 自定义 ElevatedButton 部件的主题
      1. 实现
      2. 示例
    25. expansionTileTheme: 自定义 ExpansionTile 部件的主题
      1. 实现
      2. 示例
    26. filledButtonTheme: 自定义 FilledButton 部件的主题
      1. 实现
      2. 示例
    27. floatingActionButtonTheme: 自定义 FloatingActionButton 部件的主题
      1. 实现
      2. 示例
    28. focusColor: 聚焦时的颜色
      1. 实现
      2. 示例
    29. hintColor: 提示文本或占位符文本的颜色
      1. 实现
      2. 示例
    30. iconButtonTheme: 自定义 IconButton 部件的主题
      1. 实现
      2. 示例
    31. iconTheme: 自定义图标样式
      1. 实现
      2. 示例
    32. inputDecorationTheme: 输入框装饰样式
      1. 实现
      2. 示例
    33. listTileTheme: 自定义 ListTile 部件的主题
      1. 实现
      2. 示例
    34. materialTapTargetSize: 配置 Material 部件的点击目标大小
      1. 实现
      2. 示例
    35. menuBarTheme: 自定义 MenuBar 部件的主题
      1. 实现
      2. 示例
    36. menuButtonTheme: 自定义 SubmenuButton MenuItemButton 部件的主题
      1. 实现
      2. 示例
    37. menuTheme: 自定义 SubmenuButton 部件的主题
      1. 实现
      2. 示例
    38. navigationBarTheme: 自定义 NavigationBar 部件的主题
      1. 实现
      2. 示例
    39. navigationDrawerTheme: 自定义 NavigationDrawer 部件的主题
      1. 实现
      2. 示例
    40. navigationRailTheme: 自定义 NavigationRail 部件的主题
      1. 实现
      2. 示例
    41. outlinedButtonTheme: 自定义 OutlinedButton 部件的主题
      1. 实现
      2. 示例
    42. pageTransitionsTheme: 自定义 MaterialPageRoute 主题
      1. 实现
      2. 示例
    43. platform: 应用程序的平台样式
      1. 实现
      2. 示例
    44. popupMenuTheme: 自定义 PopupMenu 相关部件的主题
      1. 实现
      2. 示例
    45. progressIndicatorTheme: 自定义 ProgressIndicator 相关部件的主题
      1. 实现
      2. 示例
    46. radioTheme: 自定义 Radio 部件的主题
      1. 实现
      2. 示例
    47. scaffoldBackgroundColor: Scaffold的背景色
      1. 实现
      2. 示例
    48. searchBarTheme: 自定义 SearchBar 部件的主题
      1. 实现
      2. 示例
    49. searchViewTheme: 自定义 SearchAnchor 部件的主题
      1. 实现
      2. 示例
    50. segmentedButtonTheme: 自定义 SegmentedButton 部件的主题
      1. 实现
      2. 示例
    51. sliderTheme: 自定义 Slider 部件的主题
      1. 实现
      2. 示例
    52. snackBarTheme: 自定义 SnackBar 部件的主题
      1. 实现
      2. 示例
    53. splashColor: InkWell点击的水波纹颜色
      1. 实现
      2. 示例
    54. splashFactory: InkWell点击的水波纹效果
      1. 实现
      2. 示例
    55. switchTheme: 自定义 Switch 部件的主题
      1. 实现
      2. 示例
    56. tabBarTheme: 自定义 TabBar 部件的主题
      1. 实现
      2. 示例
    57. textButtonTheme: 自定义 TextButton 部件的主题
      1. 实现
      2. 示例
    58. textSelectionTheme: 自定义类似 TextField 部件的文本选择的主题
      1. 实现
      2. 示例
    59. textTheme: 文本样式
      1. 示例
      2. 实现
    60. timePickerTheme: 自定义 TimePickerDialog 部件的主题
      1. 实现
      2. 示例
    61. toggleButtonsTheme: 自定义 ToggleButtons 部件的主题
      1. 实现
      2. 示例
    62. tooltipTheme: 自定义 Tooltip 部件的主题
      1. 实现
      2. 示例
  3. 构造函数
    1. 构造函数一览

文章目录

当前版本 Flutter 3.19.5

前言

ThemeData是Flutter中用于定义应用程序整体样式的类。它包含了许多属性,如主色调、强调色、字体样式、文本样式、按钮样式等,可以通过设置这些属性来统一调整应用程序的外观和风格。

另外,ThemeData还可以用来定义特定部件的样式,比如AppBar的背景色、阴影高度、标题文本样式等。这样,你就可以针对不同的部件设置不同的样式,使得应用程序的整体风格更加统一和美观。

ThemeData API

属性

属性一览

fontFamily: 应用程序的默认字体样式

ThemeData(
  fontFamily: 'Roboto', // 设置字体样式为Roboto
)

actionIconTheme: 动作图标主题

用于自定义 BackButtonIcon、CloseButtonIcon、 DrawerButtonIcon 或 EndDrawerButtonIcon 图标的主题。

实现

final ActionIconThemeData? actionIconTheme;

示例

ThemeData(
  actionIconTheme: ActionIconThemeData(
    backButtonIconBuilder: (BuildContext context) => const Icon(Icons.abc),
  )
)

appBarTheme: 自定义 AppBar 部件的主题

用于自定义AppBar的颜色、高度、亮度、iconTheme 和 textTheme 的主题。

实现

final AppBarTheme appBarTheme;

示例

ThemeData(
  appBarTheme: AppBarTheme( // 设置AppBar样式
    backgroundColor: Colors.blue, // 设置AppBar的背景色
    elevation: 0, // 设置AppBar的阴影高度为0
    textTheme: TextTheme( // 设置AppBar的文本样式
      headline6: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white), // 设置标题文本样式
    ),
  ),
)

完整的AppBarTheme用法详解

applyElevationOverlayColor: 是否应用elevation覆盖颜色

实现

final bool applyElevationOverlayColor;

示例

ThemeData(
  applyElevationOverlayColor: true
)

badgeTheme: 自定义 Badge 部件的主题

Flutter入门: ThemeData详解 - 第1张图片

实现

final BadgeThemeData badgeTheme;

示例

ThemeData(
  badgeTheme: BadgeThemeData(
    textColor: Colors.yellow,
    backgroundColor: Colors.green,
  ),
)

bannerTheme: 自定义 MaterialBanner 部件的主题<

实现

final MaterialBannerThemeData bannerTheme;

示例

ThemeData(
  bannerTheme: MaterialBannerThemeData(
    backgroundColor: Colors.green,
    contentTextStyle: const TextStyle(color: Colors.red),
    leadingPadding: const EdgeInsets.all(20),
  )
)

bottomAppBarTheme: 自定义 BottomAppBar 部件的主题

实现

final BottomAppBarTheme bottomAppBarTheme;

示例

ThemeData(
  bottomAppBarTheme: const BottomAppBarTheme(
    color: Colors.green,
  )
)

bottomSheetTheme: 自定义 BottomSheet 部件的主题

实现

final BottomSheetThemeData bottomSheetTheme;

示例

ThemeData(
  bottomSheetTheme: const BottomSheetThemeData(
    backgroundColor: Colors.green,
  )
)

brightness: 应用程序的亮度模式

实现

Brightness get brightness => colorScheme.brightness;

示例

ThemeData(
  brightness: Brightness.light, // 设置应用程序的亮度模式为明亮模式
)

buttonBarTheme: 自定义 ButtonBar 部件的主题

实现

final ButtonBarThemeData buttonBarTheme;

示例

ThemeData(
  buttonBarTheme: const ButtonBarThemeData(
    alignment: MainAxisAlignment.end,
  )
)

cardTheme: 自定义 Card 部件的主题

实现

final CardTheme cardTheme;

示例

ThemeData(
  cardTheme: CardTheme(
    color: Colors.white, // 设置卡片的背景色为白色
    elevation: 4, // 设置卡片的阴影高度为4
  ),
)

checkboxTheme: 自定义 Checkbox 部件的主题

实现

final CheckboxThemeData checkboxTheme;

示例

ThemeData(
  checkboxTheme: const CheckboxThemeData(
    checkColor: MaterialStatePropertyAll(Colors.red),
    fillColor: MaterialStatePropertyAll(Colors.green),
  ),
)

chipTheme: 自定义 Chip 部件的主题

实现

final ChipThemeData chipTheme;

示例

ThemeData(
  chipTheme: const ChipThemeData(
    backgroundColor: Colors.red,
  ),
)

colorScheme: 快速创建应用程序的颜色主题

ColorScheme是一种用于定义颜色的Flutter类,它包含了在应用程序中使用的常见颜色属性。

ColorScheme类包含

  • primary(主要颜色)
  • secondary(辅助色)
  • background(背景颜色)
  • surface(表面颜色)
  • error(错误颜色)
  • onPrimary(主要文字颜色)
  • onSecondary(辅助文字颜色)
  • onBackground(背景文字颜色)
  • onSurface(表面文字颜色)

实现

final ColorScheme colorScheme;

示例

ThemeData(
  colorScheme: const ColorScheme(
    primary: Colors.yellow,
    secondary: Colors.blue,
    surface: Colors.white,
    background: Colors.white,
    error: Colors.red,
    onError: Colors.white,
    brightness: Brightness.light,
    onPrimary: Colors.black,
    onSecondary: Colors.black,
    onBackground: Colors.black,
    onSurface: Colors.black,
  ),
)

cupertinoOverrideTheme: 覆盖Cupertino风格主题

实现

final NoDefaultCupertinoThemeData? cupertinoOverrideTheme;

示例

ThemeData(
  cupertinoOverrideTheme: const CupertinoThemeData(
    primaryColor: Colors.yellow,
    brightness: Brightness.light,
    textTheme: CupertinoTextThemeData(
      textStyle: TextStyle(
        fontFamily: 'Times New Roman',
      )
    )
  ),
)

dataTableTheme: 自定义 DataTable 部件的主题

实现

final NoDefaultCupertinoThemeData? cupertinoOverrideTheme;

示例

ThemeData(
  dataTableTheme: const DataTableThemeData(
    dataRowColor: MaterialStatePropertyAll(Colors.green),
  ),
)

datePickerTheme: 自定义 DatePickerDialog 部件的主题

实现

final DatePickerThemeData datePickerTheme;

示例

ThemeData(
  datePickerTheme: const DatePickerThemeData(
    backgroundColor: Colors.red,
  ),
)

dialogBackgroundColor: Dialog 背景颜色

实现

final Color dialogBackgroundColor;

示例

ThemeData(
  dialogBackgroundColor: Colors.red,
)

dialogTheme: 自定义 Dialog 主题

实现

final DialogTheme dialogTheme;

示例

ThemeData(
  dialogTheme: DialogTheme(
    backgroundColor: Colors.white, // 设置对话框的背景色为白色
    elevation: 8, // 设置对话框的阴影高度为8
  ),
)

dividerTheme: 分割线样式

用于自定义[Divider]、[VerticalDivider] 等的主题

实现

final DividerThemeData dividerTheme;

示例

ThemeData(
  dividerTheme: DividerThemeData(
    color: Colors.grey, // 设置分割线的颜色为灰色
    thickness: 1, // 设置分割线的厚度为1
  ),
)

drawerTheme: 自定义 Drawer 部件的主题

实现

final DrawerThemeData drawerTheme;

示例

ThemeData(
  drawerTheme: const DrawerThemeData(
    backgroundColor: Colors.yellow,
  ),
)

实现

final DropdownMenuThemeData dropdownMenuTheme;

示例

ThemeData(
  dropdownMenuTheme: const DropdownMenuThemeData(
    menuStyle: MenuStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.yellow),
    )
  ),
)

elevatedButtonTheme: 自定义 ElevatedButton 部件的主题

实现

final ElevatedButtonThemeData elevatedButtonTheme;

示例

ThemeData(
  elevatedButtonTheme: const ElevatedButtonThemeData(
    style: ButtonStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.yellow),
    )
  ),
)

expansionTileTheme: 自定义 ExpansionTile 部件的主题

实现

final ExpansionTileThemeData expansionTileTheme;

示例

ThemeData(
  expansionTileTheme: const ExpansionTileThemeData(
    collapsedIconColor: Colors.red,
  ),
)

filledButtonTheme: 自定义 FilledButton 部件的主题

实现

final FilledButtonThemeData filledButtonTheme;

示例

ThemeData(
  filledButtonTheme: const FilledButtonThemeData(
    style: ButtonStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.yellow),
    )
  ),
)

floatingActionButtonTheme: 自定义 FloatingActionButton 部件的主题

实现

final FloatingActionButtonThemeData floatingActionButtonTheme;

示例

ThemeData(
  floatingActionButtonTheme: const FloatingActionButtonThemeData(
    backgroundColor: Colors.yellow,
  ),
)

focusColor: 聚焦时的颜色

类似 DropdownButton 这样的部件聚焦时的颜色

实现

final Colors focusColor;

示例

ThemeData(
  focusColor: Colors.green,
)

hintColor: 提示文本或占位符文本的颜色

类似 TextField 这样的部件中修改 hintText 的颜色

实现

final Colors hintColor;

示例

ThemeData(
  hintColor: Colors.green,
)

iconButtonTheme: 自定义 IconButton 部件的主题

实现

final IconButtonThemeData iconButtonTheme;

示例

ThemeData(
  iconButtonTheme: const IconButtonThemeData(
    style: ButtonStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.yellow),
    )
  ),
)

iconTheme: 自定义图标样式

实现

final IconButtonThemeData iconTheme;

示例

ThemeData(
  iconTheme: const IconThemeData(
    color: Colors.red,
    size: 100,
  ),
)

inputDecorationTheme: 输入框装饰样式

自定义类似 DropdownMenu 的输入框样式

实现

final InputDecorationTheme inputDecorationTheme;

示例

ThemeData(
  inputDecorationTheme: const InputDecorationTheme(
    border: OutlineInputBorder(), // 设置输入框的边框样式为带边界的线框
    fillColor: Colors.white, // 设置输入框的填充颜色为白色
  ),
)

listTileTheme: 自定义 ListTile 部件的主题

实现

final ListTileThemeData listTileTheme;

示例

ThemeData(
  listTileTheme: const ListTileThemeData(
    iconColor: Colors.yellow,
  ),
)

materialTapTargetSize: 配置 Material 部件的点击目标大小

实现

final MaterialTapTargetSize materialTapTargetSize;

示例

ThemeData(
  materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
)

实现

final MenuBarThemeData menuBarTheme;

示例

ThemeData(
  menuBarTheme: const MenuBarThemeData(
    style: MenuStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.yellow),
    ),
  ),
)

实现

final MenuButtonThemeData menuButtonTheme;

示例

ThemeData(
  menuButtonTheme: const MenuButtonThemeData(
    style: ButtonStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.red),
    )
  ),
)

实现

final MenuThemeData menuTheme;

示例

ThemeData(
  menuTheme: const MenuThemeData(
    style: MenuStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.purple),
    ),
  ),
)

实现

final NavigationBarThemeData navigationBarTheme;

示例

ThemeData(
  navigationBarTheme: const NavigationBarThemeData(
    indicatorColor: Colors.yellow,
    backgroundColor: Colors.purple,
  ),
)

实现

final NavigationDrawerThemeData navigationDrawerTheme;

示例

ThemeData(
  navigationDrawerTheme: const NavigationDrawerThemeData(
    indicatorColor: Colors.yellow,
    backgroundColor: Colors.purple,
  ),
)

实现

final NavigationRailThemeData navigationRailTheme;

示例

ThemeData(
  navigationRailTheme: const NavigationRailThemeData(
    backgroundColor: Colors.purple,
  ),
)

outlinedButtonTheme: 自定义 OutlinedButton 部件的主题

实现

final OutlinedButtonThemeData outlinedButtonTheme;

示例

ThemeData(
  outlinedButtonTheme: const OutlinedButtonThemeData(
    style: ButtonStyle(
      backgroundColor: MaterialStatePropertyAll(Colors.purple),
      foregroundColor: MaterialStatePropertyAll(Colors.yellow),
    )
  ),
)

pageTransitionsTheme: 自定义 MaterialPageRoute 主题

实现

final PageTransitionsTheme pageTransitionsTheme;

示例

ThemeData(
  pageTransitionsTheme: const PageTransitionsTheme(
    builders: {
      TargetPlatform.android: ZoomPageTransitionsBuilder(),
      TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
    }
  ),
)

platform: 应用程序的平台样式

实现

final TargetPlatform platform;

示例

ThemeData(
  platform: TargetPlatform.android, // 设置应用程序的平台样式为Android
)

popupMenuTheme: 自定义 PopupMenu 相关部件的主题

实现

final PopupMenuThemeData popupMenuTheme;

示例

ThemeData(
  popupMenuTheme: const PopupMenuThemeData(
    color: Colors.purple,
    shape: StadiumBorder(),
  ),
)

progressIndicatorTheme: 自定义 ProgressIndicator 相关部件的主题

实现

final ProgressIndicatorThemeData progressIndicatorTheme;

示例

ThemeData(
  progressIndicatorTheme: const ProgressIndicatorThemeData(
    color: Colors.yellow,
    linearMinHeight: 20,
  ),
)

radioTheme: 自定义 Radio 部件的主题

实现

final RadioThemeData radioTheme;

示例

ThemeData(
  radioTheme: const RadioThemeData(
    fillColor: MaterialStatePropertyAll(Colors.yellow),
  ),
)

scaffoldBackgroundColor: Scaffold的背景色

实现

final Color scaffoldBackgroundColor;

示例

ThemeData(
  scaffoldBackgroundColor: Colors.grey[200], // 设置Scaffold的背景色为灰色
)

searchBarTheme: 自定义 SearchBar 部件的主题

实现

final SearchBarThemeData searchBarTheme;

示例

ThemeData(
  searchBarTheme: const SearchBarThemeData(
    backgroundColor: MaterialStatePropertyAll(Colors.yellow),
  ),
)

searchViewTheme: 自定义 SearchAnchor 部件的主题

实现

final SearchViewThemeData searchViewTheme;

示例

ThemeData(
  searchViewTheme: const SearchViewThemeData(
    backgroundColor: Colors.red,
  ),
)

segmentedButtonTheme: 自定义 SegmentedButton 部件的主题

实现

final SegmentedButtonThemeData segmentedButtonTheme;

示例

ThemeData(
  segmentedButtonTheme: const SegmentedButtonThemeData(
    selectedIcon: Icon(Icons.star, color: Colors.blue),
  ),
)

sliderTheme: 自定义 Slider 部件的主题

实现

final SliderThemeData sliderTheme;

示例

ThemeData(
  sliderTheme: const SliderThemeData(
    activeTrackColor: Colors.red,
  ),
)

snackBarTheme: 自定义 SnackBar 部件的主题

实现

final SnackBarThemeData snackBarTheme;

示例

ThemeData(
  snackBarTheme: const SnackBarThemeData(
    backgroundColor: Colors.red,
  ),
)

splashColor: InkWell点击的水波纹颜色

实现

final Color splashColor;

示例

ThemeData(
  splashColor: Colors.red,
)

splashFactory: InkWell点击的水波纹效果

实现

final InteractiveInkFeatureFactory splashFactory;

示例

ThemeData(
  splashFactory: InkSparkle.splashFactory,
  // splashFactory: InkRipple.splashFactory,
)

switchTheme: 自定义 Switch 部件的主题

实现

final SwitchThemeData switchTheme;

示例

ThemeData(
  switchTheme: const SwitchThemeData(
    thumbColor: MaterialStatePropertyAll(Colors.yellow),
  ),
)

tabBarTheme: 自定义 TabBar 部件的主题

实现

final TabBarTheme tabBarTheme;

示例

ThemeData(
  tabBarTheme: const TabBarTheme(
    indicator: UnderlineTabIndicator(
      borderSide: BorderSide(color: Colors.red, width: 2),
      insets: EdgeInsets.symmetric(horizontal: 50),
    )
  ),
)

textButtonTheme: 自定义 TextButton 部件的主题

实现

final TextButtonThemeData textButtonTheme;

示例

ThemeData(
  textButtonTheme: TextButtonThemeData(
    style: ButtonStyle(
      foregroundColor: MaterialStatePropertyAll(Colors.yellow),
      overlayColor: MaterialStatePropertyAll(Colors.red),
      backgroundColor: MaterialStatePropertyAll(Colors.purple),
    )
  ),
)

textSelectionTheme: 自定义类似 TextField 部件的文本选择的主题

实现

final TextSelectionThemeData textSelectionTheme;

示例

ThemeData(
  textSelectionTheme: const TextSelectionThemeData(
    cursorColor: Colors.red,
    selectionColor: Colors.yellow,
  ),
)

textTheme: 文本样式

final TextTheme textTheme;

示例

ThemeData(
  textTheme: const TextTheme( // 设置文本样式
    headlineLarge: TextStyle(fontSize: 24, color: Colors.red), // 设置标题文本样式
  ),
)

完整的TextTheme用法详解

实现

timePickerTheme: 自定义 TimePickerDialog 部件的主题

实现

final TimePickerThemeData timePickerTheme;

示例

ThemeData(
  timePickerTheme: const TimePickerThemeData(
    backgroundColor: Colors.red,
  ),
)

toggleButtonsTheme: 自定义 ToggleButtons 部件的主题

实现

final ToggleButtonsThemeData toggleButtonsTheme;

示例

ThemeData(
  toggleButtonsTheme: const ToggleButtonsThemeData(
    selectedColor: Colors.red,
    fillColor: Colors.yellow,
  ),
)

tooltipTheme: 自定义 Tooltip 部件的主题

实现

final TooltipThemeData tooltipTheme;

示例

ThemeData(
  tooltipTheme: const TooltipThemeData(
    decoration: BoxDecoration(
      color: Colors.red,
    ),
    textStyle: TextStyle(color: Colors.yellow),
  ),
)

构造函数

构造函数一览

  • dark: 创建一个暗色主题的ThemeData实例
  • light: 创建一个亮色主题的ThemeData实例
  • fallback: 创建一个主题数据的副本,但使用给定的属性值作为默认值
  • from: 从一个主题数据对象中创建一个新的主题数据对象
  • raw: 根据给定的值创建一个主题数据对象,通常用于从JSON等数据源创建主题

...完结...

《Flutter入门: ThemeData详解》留言数:0

发表留言