Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6. @override
  7. Widget build(BuildContext context) {
  8. // Color for App bar BG, Card BG, RaisedButton BG, FloatingButton BG
  9. Color primary = Colors.red;
  10.  
  11. // Color for text where the primary color is the background
  12. Color accent = Colors.yellowAccent;
  13.  
  14. // Any other text color
  15. Color black = Colors.black;
  16.  
  17. return MaterialApp(
  18. title: 'Flutter Demo',
  19. theme: ThemeData(
  20. primarySwatch: Colors.redAccent[800],
  21. primaryColor: primary,
  22. accentColor: accent,
  23. brightness: Brightness.light,
  24. primaryIconTheme: IconThemeData(color: accent),
  25. accentIconTheme: IconThemeData(color: accent),
  26. iconTheme: IconThemeData(color: accent),
  27. cardColor: primary,
  28. buttonColor: primary,
  29. buttonTheme: ButtonThemeData(
  30. textTheme: ButtonTextTheme.accent,
  31. buttonColor: primary,
  32. ),
  33. primaryTextTheme: TextTheme(
  34. title: TextStyle(color: accent),
  35. button: TextStyle(color: black),
  36. ),
  37. accentTextTheme: TextTheme(
  38. title: TextStyle(color: black),
  39. button: TextStyle(color: black),
  40. ),
  41. textTheme: TextTheme(
  42. title: TextStyle(color: black),
  43. button: TextStyle(color: black),
  44. ),
  45. ),
  46. home: MyHomePage(title: 'Flutter Demo Home Page'),
  47. );
  48. }
  49. }
  50.  
  51. class MyHomePage extends StatefulWidget {
  52. MyHomePage({Key key, this.title}) : super(key: key);
  53.  
  54. final String title;
  55.  
  56. @override
  57. _MyHomePageState createState() => _MyHomePageState();
  58. }
  59.  
  60. class _MyHomePageState extends State<MyHomePage> {
  61. void _incrementCounter() {
  62. showDialog(
  63. context: context,
  64. builder: (BuildContext context) {
  65. return AlertDialog(
  66. title: new Text("Foo bar"),
  67. content: new Text(
  68. "The delete button is set manually to ButtonTextTheme.primary to be red, it´s fine. But the keep button defaults to the ThemeData.accentColor"),
  69. actions: <Widget>[
  70. new FlatButton(
  71. textTheme: ButtonTextTheme.primary,
  72. child: new Text(
  73. "Delete",
  74. style: TextStyle(color: Theme.of(context).primaryColor),
  75. ),
  76. onPressed: () {
  77. Navigator.of(context).pop();
  78. },
  79. ),
  80. new FlatButton(
  81. child: new Text("Keep"),
  82. onPressed: () {
  83. Navigator.of(context).pop();
  84. },
  85. ),
  86. ],
  87. );
  88. },
  89. );
  90. }
  91.  
  92. @override
  93. Widget build(BuildContext context) {
  94. return Scaffold(
  95. drawer: Drawer(),
  96. appBar: AppBar(
  97. title: Text(widget.title),
  98. ),
  99. body: Center(
  100. child: Column(
  101. mainAxisAlignment: MainAxisAlignment.center,
  102. children: <Widget>[
  103. Text(
  104. 'Floating action button background color should be the primary red, not the yellow accent color. Like the AppBar+DrawerIcon',
  105. )
  106. ],
  107. ),
  108. ),
  109. floatingActionButton: FloatingActionButton(
  110. onPressed: _incrementCounter,
  111. tooltip: 'Increment',
  112. child: Icon(Icons.add),
  113. ), // This trailing comma makes auto-formatting nicer for build methods.
  114. );
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement