Created
September 26, 2018 07:58
-
-
Save figengungor/fb29f0e11f2fb8f8c6a64dbbf31ba8a3 to your computer and use it in GitHub Desktop.
TextTheme display4 issue
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/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
@override | |
MyAppState createState() { | |
return new MyAppState(); | |
} | |
} | |
class MyAppState extends State<MyApp> { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
canvasColor: Colors.pinkAccent), | |
home: HomePage(), | |
); | |
} | |
} | |
class HomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return DefaultTabController( | |
length: 3, | |
child: Scaffold( | |
appBar: AppBar( | |
title: Text('TextTheme display 4 issue'), | |
bottom: TabBar( | |
isScrollable: true, | |
tabs: [ | |
Tab(text: 'textTheme'), | |
Tab(text: 'primaryTextTheme'), | |
Tab(text: 'accentTextTheme'), | |
], | |
), | |
), | |
body: _getBody(context), | |
), | |
); | |
} | |
_getBody(BuildContext context) { | |
return TabBarView( | |
children: <Widget>[ | |
TextThemeTabView( | |
title: "textTheme", | |
textTheme: Theme.of(context).textTheme, | |
), | |
TextThemeTabView( | |
title: "primaryTextTheme", | |
textTheme: Theme.of(context).primaryTextTheme, | |
), | |
TextThemeTabView( | |
title: "accentTextTheme", | |
textTheme: Theme.of(context).accentTextTheme, | |
), | |
], | |
); | |
} | |
} | |
class TextThemeTabView extends StatelessWidget { | |
final String title; | |
final TextTheme textTheme; | |
const TextThemeTabView({Key key, this.title, this.textTheme}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: <Widget>[ | |
Expanded(child: _buildList()), | |
], | |
); | |
} | |
_buildList() => ListView( | |
children: <Widget>[ | |
Text( | |
"Display 4", | |
style: textTheme.display4, | |
), | |
Text( | |
"Display 3", | |
style: textTheme.display3, | |
), | |
Text( | |
"Display 2", | |
style: textTheme.display2, | |
), | |
Text( | |
"Display 1", | |
style: textTheme.display1, | |
), | |
Text( | |
"Headline", | |
style: textTheme.headline, | |
), | |
Text( | |
"Title", | |
style: textTheme.title, | |
), | |
Text( | |
"Subhead", | |
style: textTheme.subhead, | |
), | |
Text( | |
"Body 2", | |
style: textTheme.body2, | |
), | |
Text( | |
"Body 1", | |
style: textTheme.body1, | |
), | |
Text( | |
"Caption", | |
style: textTheme.caption, | |
), | |
Text( | |
"Button", | |
style: textTheme.button, | |
), | |
], | |
); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment