当前位置:网站首页>[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 )
边栏推荐
- [Jianzhi offer] 57 And are two numbers of S
- 加了定位的文字如何水平垂直居中
- pip安裝whl文件報錯:ERROR: ... is not a supported wheel on this platform
- Kubernetes resource object introduction and common commands (4)
- TinyMCE visual editor adds Baidu map plug-in
- 一周生活
- SQL必需掌握的100个重要知识点:管理事务处理
- Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file
- From personal heroes to versatile developers, the era of programmer 3.0 is coming
- Image segmentation using pixellib
猜你喜欢
[shutter] shutter gesture interaction (small ball following the movement of fingers)
kubernetes资源对象介绍及常用命令(四)
Browser - clean up the cache of JS in the page
What "real skills" should a million year old cloud native developer master? Alibaba, Tencent, meituan and byte decrypt together
MySQL learning record (7)
[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
C language, to achieve three chess games
How to prevent your jar from being decompiled?
Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file
How to test the process of restoring backup files?
随机推荐
Interpretation of CVPR paper | generation of high fidelity fashion models with weak supervision
Pyqt picture decodes and encodes and loads pictures
SQL必需掌握的100个重要知识点:管理事务处理
ArrayList analysis 2: pits in ITR, listiterator, and sublist
【leetcode】1380. Lucky number in matrix
关于PHP-数据库的 数据读取,Trying to get property 'num_rows' of non-object?
MySQL learning record (7)
Attack and defense world PWN question: Echo
Browser - clean up the cache of JS in the page
Technological Entrepreneurship: failure is not success, but reflection is
How to write a good program when a big book speaks every day?
MySQL learning record (8)
Les trois principaux points de douleur traités par servicemesh
2019 Nanchang (relive the classic)
Record the functions of sharing web pages on wechat, QQ and Weibo
Lightgbm principle and its application in astronomical data
Leetcode theme [array] -169- most elements
Kubernetes resource object introduction and common commands (4)
Secondary development of ANSYS APDL: post processing uses command flow to analyze the result file
A specially designed loss is used to deal with data sets with unbalanced categories