Created
February 15, 2020 14:05
-
-
Save jimit24365/929069c638794dbd3f4d081b61ebed13 to your computer and use it in GitHub Desktop.
This file contains 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: 'Georgia', | |
// Define the default TextTheme. Use this to specify the default | |
// text styling for headlines, titles, bodies of text, and more. | |
textTheme: TextTheme( | |
headline5: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold), | |
headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic), | |
bodyText2: 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.headline6, | |
), | |
), | |
), | |
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