Created
November 26, 2019 16:45
-
-
Save brianegan/800ae35e1b732c93440eaa9faf9e5e9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
final appName = 'Custom Themes'; | |
return MaterialApp( | |
title: appName, | |
theme: ThemeData( | |
// Define the default brightness and colors. | |
brightness: Brightness.dark, | |
primaryColor: Colors.lightBlue[800], | |
accentColor: Colors.cyan[600], | |
// Define the default font family. | |
fontFamily: 'Montserrat', | |
// Define the default TextTheme. Use this to specify the default | |
// text styling for headlines, titles, bodies of text, and more. | |
textTheme: TextTheme( | |
headline: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold), | |
title: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic), | |
body1: TextStyle(fontSize: 14.0, fontFamily: 'Hind'), | |
), | |
), | |
home: 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 Scaffold( | |
appBar: AppBar( | |
title: Text(title), | |
), | |
body: Center( | |
child: Container( | |
color: Theme.of(context).accentColor, | |
child: Text( | |
'Text with a background color', | |
style: Theme.of(context).textTheme.title, | |
), | |
), | |
), | |
floatingActionButton: Theme( | |
data: Theme.of(context).copyWith( | |
colorScheme: | |
Theme.of(context).colorScheme.copyWith(secondary: Colors.yellow), | |
), | |
child: FloatingActionButton( | |
onPressed: null, | |
child: Icon(Icons.add), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment