Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- // Color for App bar BG, Card BG, RaisedButton BG, FloatingButton BG
- Color primary = Colors.red;
- // Color for text where the primary color is the background
- Color accent = Colors.yellowAccent;
- // Any other text color
- Color black = Colors.black;
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.redAccent[800],
- primaryColor: primary,
- accentColor: accent,
- brightness: Brightness.light,
- primaryIconTheme: IconThemeData(color: accent),
- accentIconTheme: IconThemeData(color: accent),
- iconTheme: IconThemeData(color: accent),
- cardColor: primary,
- buttonColor: primary,
- buttonTheme: ButtonThemeData(
- textTheme: ButtonTextTheme.accent,
- buttonColor: primary,
- ),
- primaryTextTheme: TextTheme(
- title: TextStyle(color: accent),
- button: TextStyle(color: black),
- ),
- accentTextTheme: TextTheme(
- title: TextStyle(color: black),
- button: TextStyle(color: black),
- ),
- textTheme: TextTheme(
- title: TextStyle(color: black),
- button: TextStyle(color: black),
- ),
- ),
- home: MyHomePage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
- final String title;
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- void _incrementCounter() {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return AlertDialog(
- title: new Text("Foo bar"),
- content: new Text(
- "The delete button is set manually to ButtonTextTheme.primary to be red, it´s fine. But the keep button defaults to the ThemeData.accentColor"),
- actions: <Widget>[
- new FlatButton(
- textTheme: ButtonTextTheme.primary,
- child: new Text(
- "Delete",
- style: TextStyle(color: Theme.of(context).primaryColor),
- ),
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- new FlatButton(
- child: new Text("Keep"),
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- ],
- );
- },
- );
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- drawer: Drawer(),
- appBar: AppBar(
- title: Text(widget.title),
- ),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text(
- 'Floating action button background color should be the primary red, not the yellow accent color. Like the AppBar+DrawerIcon',
- )
- ],
- ),
- ),
- floatingActionButton: FloatingActionButton(
- onPressed: _incrementCounter,
- tooltip: 'Increment',
- child: Icon(Icons.add),
- ), // This trailing comma makes auto-formatting nicer for build methods.
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement