flat_button.dart 1.33 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'package:flutter/widgets.dart';
6 7 8

import 'material_button.dart';
import 'theme.dart';
9 10 11

class FlatButton extends MaterialButton {
  FlatButton({
12
    Key key,
13
    Widget child,
14 15 16 17 18 19
    ButtonColor textTheme,
    Color textColor,
    Color disabledTextColor,
    this.color,
    this.colorBrightness,
    this.disabledColor,
20
    VoidCallback onPressed
21 22
  }) : super(key: key,
             child: child,
23 24 25
             textTheme: textTheme,
             textColor: textColor,
             disabledTextColor: disabledTextColor,
26 27
             onPressed: onPressed);

28 29 30 31 32 33 34
  // These default to null, meaning transparent.
  final Color color;
  final Color disabledColor;

  /// Controls the default text color if the text color isn't explicit set.
  final ThemeBrightness colorBrightness;

35
  _FlatButtonState createState() => new _FlatButtonState();
36 37
}

38
class _FlatButtonState extends MaterialButtonState<FlatButton> {
39

Hans Muller's avatar
Hans Muller committed
40
  int get elevation => 0;
41

42 43 44 45
  Color getColor(BuildContext context) {
    if (!config.enabled)
      return config.disabledColor;
    return config.color;
46 47
  }

48
  ThemeBrightness getColorBrightness(BuildContext context) {
49
    return config.colorBrightness ?? Theme.of(context).brightness;
50 51
  }

52
}