mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This fixes some theoretical bugs whereby we were using hashCode to try
to get unique keys for objects, but really we wanted object identity.
It also lays the groundwork for a new GlobalKey concept.
I tried to keep the impact on the code minimal, which is why the "Key"
constructor is actually a factory that returns a StringKey. The code
has this class hierarchy:
```
KeyBase
|
Key--------------+---------------+
| | |
StringKey ObjectKey UniqueKey
```
...where the constructors are Key and Key.stringify (StringKey),
Key.fromObjectIdentity (ObjectKey), and Key.unique (UniqueKey).
We could instead of factory methods use regular constructors with the
following hierarchy:
```
KeyBase
|
LocalKey---------+---------------+
| | |
Key ObjectIdentityKey UniqueKey
```
...with constructors Key, Key.stringify, ObjectIdentityKey, and
UniqueKey, but I felt that that was maybe a more confusing hierarchy.
I don't have a strong opinion on this.
34 lines
859 B
Dart
34 lines
859 B
Dart
// 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.
|
|
|
|
import 'package:sky/theme/colors.dart';
|
|
import 'package:sky/widgets/basic.dart';
|
|
import 'package:sky/widgets/material_button.dart';
|
|
import 'package:sky/widgets/theme.dart';
|
|
|
|
class FlatButton extends MaterialButton {
|
|
FlatButton({
|
|
Key key,
|
|
Widget child,
|
|
bool enabled: true,
|
|
Function onPressed
|
|
}) : super(key: key,
|
|
child: child,
|
|
enabled: enabled,
|
|
onPressed: onPressed);
|
|
|
|
Color get color {
|
|
if (!enabled || !highlight)
|
|
return null;
|
|
switch (Theme.of(this).brightness) {
|
|
case ThemeBrightness.light:
|
|
return Grey[400];
|
|
case ThemeBrightness.dark:
|
|
return Grey[200];
|
|
}
|
|
}
|
|
|
|
int get level => 0;
|
|
}
|