Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
497b9deb
Unverified
Commit
497b9deb
authored
Apr 10, 2018
by
Ian Hickson
Committed by
GitHub
Apr 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanup of Chips that I found while learning the code. (#16249)
parent
a7c10097
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
9 deletions
+44
-9
chip.dart
packages/flutter/lib/src/material/chip.dart
+44
-9
No files found.
packages/flutter/lib/src/material/chip.dart
View file @
497b9deb
...
...
@@ -64,6 +64,10 @@ const Icon _kDefaultDeleteIcon = const Icon(Icons.cancel, size: _kDeleteIconSize
/// * [ActionChip], represents an action related to primary content.
/// * <https://material.google.com/components/chips.html>
abstract
class
ChipAttributes
{
// This class is intended to be used as an interface, and should not be
// extended directly.
factory
ChipAttributes
.
_
()
=>
null
;
/// The primary content of the chip.
///
/// Typically a [Text] widget.
...
...
@@ -121,6 +125,10 @@ abstract class ChipAttributes {
/// compact form.
/// * <https://material.google.com/components/chips.html>
abstract
class
DeletableChipAttributes
{
// This class is intended to be used as an interface, and should not be
// extended directly.
factory
DeletableChipAttributes
.
_
()
=>
null
;
/// The icon displayed when [onDeleted] is set.
///
/// Defaults to an [Icon] widget set to use [Icons.cancel].
...
...
@@ -212,6 +220,10 @@ abstract class DeletableChipAttributes {
/// * [FilterChip], uses tags or descriptive words as a way to filter content.
/// * <https://material.google.com/components/chips.html>
abstract
class
SelectableChipAttributes
{
// This class is intended to be used as an interface, and should not be
// extended directly.
factory
SelectableChipAttributes
.
_
()
=>
null
;
/// Whether or not this chip is selected.
///
/// If [onSelected] is not null, this value will be used to determine if the
...
...
@@ -290,6 +302,10 @@ abstract class SelectableChipAttributes {
/// * [FilterChip], uses tags or descriptive words as a way to filter content.
/// * <https://material.google.com/components/chips.html>
abstract
class
DisabledChipAttributes
{
// This class is intended to be used as an interface, and should not be
// extended directly.
factory
DisabledChipAttributes
.
_
()
=>
null
;
/// Whether or not this chip is enabled for input.
///
/// If this is true, but all of the user action callbacks are null (i.e.
...
...
@@ -333,6 +349,10 @@ abstract class DisabledChipAttributes {
/// * [ActionChip], represents an action related to primary content.
/// * <https://material.google.com/components/chips.html>
abstract
class
TappableChipAttributes
{
// This class is intended to be used as an interface, and should not be
// extended directly.
factory
TappableChipAttributes
.
_
()
=>
null
;
/// Called when the user taps the chip.
///
/// If [onPressed] is set, then this callback will be called when the user
...
...
@@ -372,7 +392,7 @@ abstract class TappableChipAttributes {
/// button for deleting the chip.
///
/// Requires one of its ancestors to be a [Material] widget. The [label],
/// [deleteIcon] and [border] arguments must not be null.
/// [deleteIcon]
,
and [border] arguments must not be null.
///
/// ## Sample code
///
...
...
@@ -402,7 +422,7 @@ abstract class TappableChipAttributes {
class
Chip
extends
StatelessWidget
implements
ChipAttributes
,
DeletableChipAttributes
{
/// Creates a material design chip.
///
/// The [label], [deleteIcon] and [border] arguments must not be null.
/// The [label], [deleteIcon]
,
and [border] arguments must not be null.
const
Chip
({
Key
key
,
this
.
avatar
,
...
...
@@ -634,7 +654,7 @@ class InputChip extends StatelessWidget
/// related descriptive text or categories.
///
/// Requires one of its ancestors to be a [Material] widget. The [selected],
/// [label] and [border] arguments must not be null.
/// [label]
,
and [border] arguments must not be null.
///
/// ## Sample code
///
...
...
@@ -684,6 +704,9 @@ class ChoiceChip extends StatelessWidget
ChipAttributes
,
SelectableChipAttributes
,
DisabledChipAttributes
{
/// Create a chip that acts like a radio button.
///
/// The [selected], [label], and [border] arguments must not be null.
const
ChoiceChip
({
Key
key
,
this
.
avatar
,
...
...
@@ -849,6 +872,9 @@ class FilterChip extends StatelessWidget
ChipAttributes
,
SelectableChipAttributes
,
DisabledChipAttributes
{
/// Create a chip that acts like a checkbox.
///
/// The [selected], [label], and [border] arguments must not be null.
const
FilterChip
({
Key
key
,
this
.
avatar
,
...
...
@@ -927,17 +953,19 @@ class FilterChip extends StatelessWidget
/// content. Action chips should appear dynamically and contextually in a UI.
///
/// Action chips can be tapped to trigger an action or show progress and
/// confirmation.
/// confirmation. They cannot be disabled; if the action is not applicable, the
/// chip should not be included in the interface. (This contrasts with buttons,
/// where unavailable choices are usually represented as disabled controls.)
///
/// Action chips are displayed after primary content, such as below a card or
/// persistently at the bottom of a screen.
///
/// The material button widgets, [RaisedButton], [FlatButton],
[OutlineButton]
///
are an alternative to action chips, which should appear statically and
/// consistently in a UI.
/// The material button widgets, [RaisedButton], [FlatButton],
and
///
[OutlineButton], are an alternative to action chips, which should appear
///
statically and
consistently in a UI.
///
/// Requires one of its ancestors to be a [Material] widget. The [onPressed],
/// [label] and [border] arguments must not be null.
/// [label]
,
and [border] arguments must not be null.
///
/// ## Sample code
///
...
...
@@ -967,6 +995,9 @@ class FilterChip extends StatelessWidget
/// vertical runs.
/// * <https://material.google.com/components/chips.html>
class
ActionChip
extends
StatelessWidget
implements
ChipAttributes
,
TappableChipAttributes
{
/// Create a chip that acts like a button.
///
/// The [label], [border], and [onPressed] arguments must not be null.
const
ActionChip
({
Key
key
,
this
.
avatar
,
...
...
@@ -981,7 +1012,11 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
this
.
padding
,
})
:
assert
(
label
!=
null
),
assert
(
shape
!=
null
),
assert
(
onPressed
!=
null
),
assert
(
onPressed
!=
null
,
'Rather than disabling an ActionChip by setting onPressed to null, '
'remove it from the interface entirely.'
,
),
super
(
key:
key
);
@override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment