当前位置:网站首页>[shutter] shutter application theme (themedata | dynamic modification theme)
[shutter] shutter application theme (themedata | dynamic modification theme)
2022-07-02 22:17:00 【Programmer community】
List of articles
- One 、Flutter Application theme
- Two 、 Complete code example
- 3、 ... and 、 Related resources
One 、Flutter Application theme
Flutter Application themes are encapsulated in ThemeData Class , stay MaterialApp Of theme Field , You can set ThemeData The theme , The options that can be set are as follows , Below ThemeData The optional parameters in the factory constructor are various topic options that can be set ;
class ThemeData extends Diagnosticable {
factory ThemeData({
Brightness brightness, MaterialColor primarySwatch, Color primaryColor, Brightness primaryColorBrightness, Color primaryColorLight, Color primaryColorDark, Color accentColor, Brightness accentColorBrightness, Color canvasColor, Color scaffoldBackgroundColor, Color bottomAppBarColor, Color cardColor, Color dividerColor, Color focusColor, Color hoverColor, Color highlightColor, Color splashColor, InteractiveInkFeatureFactory splashFactory, Color selectedRowColor, Color unselectedWidgetColor, Color disabledColor, Color buttonColor, ButtonThemeData buttonTheme, ToggleButtonsThemeData toggleButtonsTheme, Color secondaryHeaderColor, Color textSelectionColor, Color cursorColor, Color textSelectionHandleColor, Color backgroundColor, Color dialogBackgroundColor, Color indicatorColor, Color hintColor, Color errorColor, Color toggleableActiveColor, String fontFamily, TextTheme textTheme, TextTheme primaryTextTheme, TextTheme accentTextTheme, InputDecorationTheme inputDecorationTheme, IconThemeData iconTheme, IconThemeData primaryIconTheme, IconThemeData accentIconTheme, SliderThemeData sliderTheme, TabBarTheme tabBarTheme, TooltipThemeData tooltipTheme, CardTheme cardTheme, ChipThemeData chipTheme, TargetPlatform platform, MaterialTapTargetSize materialTapTargetSize, bool applyElevationOverlayColor, PageTransitionsTheme pageTransitionsTheme, AppBarTheme appBarTheme, BottomAppBarTheme bottomAppBarTheme, ColorScheme colorScheme, DialogTheme dialogTheme, FloatingActionButtonThemeData floatingActionButtonTheme, Typography typography, CupertinoThemeData cupertinoOverrideTheme, SnackBarThemeData snackBarTheme, BottomSheetThemeData bottomSheetTheme, PopupMenuThemeData popupMenuTheme, MaterialBannerThemeData bannerTheme, DividerThemeData dividerTheme, ButtonBarThemeData buttonBarTheme, })}
The following code sets MaterialApp The theme of ThemeData , brightness The field is set to the theme mode , The setting here is Brightness.light Day mode ;
primarySwatch The field sets the main color of the theme , The setting here is blue ;
import 'package:flutter/material.dart';class ThemePage extends StatefulWidget {
@override _ThemePageState createState() => _ThemePageState();}class _ThemePageState extends State<ThemePage> {
@override Widget build(BuildContext context) {
return MaterialApp( title: "Theme Subject modification ", theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.blue, ), home: , ); }}
Two 、 Complete code example
Complete code example :
import 'package:flutter/material.dart';class ThemePage extends StatefulWidget {
@override _ThemePageState createState() => _ThemePageState();}class _ThemePageState extends State<ThemePage> {
/// Theme mode Brightness brightness = Brightness.light; @override Widget build(BuildContext context) {
return MaterialApp( title: "Theme Subject modification ", theme: ThemeData( brightness: brightness, primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( title: Text("Theme Subject modification "), ), body: Column( children: <Widget>[ RaisedButton( onPressed: (){
setState(() {
brightness = Brightness.light; }); }, child: Text(" Switch to the daytime theme "), ), RaisedButton( onPressed: (){
setState(() {
brightness = Brightness.dark; }); }, child: Text(" Switch to the night theme "), ), ], ), ), ); }}
Running effect :
3、 ... and 、 Related resources
Reference material :
- Flutter Official website : https://flutter.dev/
- Flutter Plug in download address : https://pub.dev/packages
- Flutter Developing documents : https://flutter.cn/docs ( Strongly recommend )
- official GitHub Address : https://github.com/flutter
- Flutter The Chinese community : https://flutter.cn/
- Flutter Practical tutorial : https://flutter.cn/docs/cookbook
- Flutter CodeLab : https://codelabs.flutter-io.cn/
- Dart Chinese document : https://dart.cn/
- Dart Developer website : https://api.dart.dev/
- Flutter Chinese net ( unofficial , The translation is very good ) : https://flutterchina.club/ , http://flutter.axuer.com/docs/
- Flutter Related issues : https://flutterchina.club/faq/ ( It is recommended to watch it at the introductory stage )
Blog source download :
GitHub Address : https://github.com/han1202012/flutter_cmd ( Keep updating with the progress of the blog , There may not be the source code of this blog )
Blog source snapshot : https://download.csdn.net/download/han1202012/15547438 ( The source code snapshot of this blog , You can find the source code of this blog )
边栏推荐
- "New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba
- Physical layer cables and equipment
- C language, to achieve three chess games
- pyqt图片解码 编码后加载图片
- "New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba
- A specially designed loss is used to deal with data sets with unbalanced categories
- "Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks!
- [Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
- Learn computer knowledge from scratch
- 如何访问kubernetes API?
猜你喜欢
Error in PIP installation WHL file: error: is not a supported wheel on this platform
C语言,实现三子棋小游戏
The source code of the daily book analyzes the design idea of Flink and solves the problems in Flink
LightGBM原理及天文数据中的应用
《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!
Ransack combined condition search implementation
pip安裝whl文件報錯:ERROR: ... is not a supported wheel on this platform
[shutter] shutter layout component (physicalmodel component)
Promise optimized callback hell
[staff] Sibelius 7.5.1 score software installation (software download | software installation)
随机推荐
[shutter] shutter gesture interaction (click event handling | click OnTap | double click | long press | click Cancel | press ontapdown | lift ontapup)
:last-child 不生效解决
PIP version update timeout - download using domestic image
C语言,实现三子棋小游戏
Necessary browser plug-ins for network security engineers
关于PHP-数据库的 数据读取,Trying to get property 'num_rows' of non-object?
Error in PIP installation WHL file: error: is not a supported wheel on this platform
【leetcode】1380. Lucky number in matrix
scrcpy这款软件解决了和同事分享手机屏幕的问题| 社区征文
[sword finger offer] 56 - I. the number of numbers in the array
腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?
MySQL learning record (7)
ServiceMesh主要解决的三大痛點
Infrastructure is code: a change is coming
记录一下微信、QQ、微博分享web网页功能
【剑指 Offer】56 - I. 数组中数字出现的次数
A specially designed loss is used to deal with data sets with unbalanced categories
20220702 how do programmers build knowledge systems?
Evolution of messaging and streaming systems under the native tide of open source cloud
kubernetes资源对象介绍及常用命令(四)