阅读背景:

Flutter学习 — 设计基础

来源:互联网 
效果图:

在这里插入图片描述

代码+注释: import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { final appName = 'Custom Themes'; return new MaterialApp( title: appName, //创建主题 theme: new ThemeData( brightness: Brightness.dark, //亮度 primaryColor: Colors.lightBlue[800], //主题颜色 accentColor: Colors.cyan[600], //其他颜色 ), home: new MyHomePage( title: appName, ), ); } } class MyHomePage extends StatelessWidget { final String title; MyHomePage({Key key, @required this.title}) : super(key: key); @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(title), ), body: new Center( child: new Container( color: Theme.of(context).accentColor, //引用主题 child: new Text( 'Text with a background color', style: Theme.of(context).textTheme.title, ), ), ), ); } } 喜欢记得点个赞哟,我叫王睿很高兴认识大家! 代码+注释: import 'package:flutter/foundation.d



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: