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
51dd5bf1
Unverified
Commit
51dd5bf1
authored
Feb 02, 2021
by
Hans Muller
Committed by
GitHub
Feb 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ButtonStyle.splashFactory and NoSplash.splashFactory (#74949)
parent
9c434c82
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
277 additions
and
7 deletions
+277
-7
material.dart
packages/flutter/lib/material.dart
+1
-0
button_style.dart
packages/flutter/lib/src/material/button_style.dart
+24
-1
button_style_button.dart
packages/flutter/lib/src/material/button_style_button.dart
+2
-2
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+6
-0
ink_ripple.dart
packages/flutter/lib/src/material/ink_ripple.dart
+2
-2
ink_splash.dart
packages/flutter/lib/src/material/ink_splash.dart
+2
-2
no_splash.dart
packages/flutter/lib/src/material/no_splash.dart
+66
-0
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+6
-0
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+6
-0
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+40
-0
ink_splash_test.dart
packages/flutter/test/material/ink_splash_test.dart
+42
-0
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+40
-0
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+40
-0
No files found.
packages/flutter/lib/material.dart
View file @
51dd5bf1
...
@@ -99,6 +99,7 @@ export 'src/material/material_state.dart';
...
@@ -99,6 +99,7 @@ export 'src/material/material_state.dart';
export
'src/material/mergeable_material.dart'
;
export
'src/material/mergeable_material.dart'
;
export
'src/material/navigation_rail.dart'
;
export
'src/material/navigation_rail.dart'
;
export
'src/material/navigation_rail_theme.dart'
;
export
'src/material/navigation_rail_theme.dart'
;
export
'src/material/no_splash.dart'
;
export
'src/material/outline_button.dart'
;
export
'src/material/outline_button.dart'
;
export
'src/material/outlined_button.dart'
;
export
'src/material/outlined_button.dart'
;
export
'src/material/outlined_button_theme.dart'
;
export
'src/material/outlined_button_theme.dart'
;
...
...
packages/flutter/lib/src/material/button_style.dart
View file @
51dd5bf1
...
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
...
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'ink_well.dart'
;
import
'material_state.dart'
;
import
'material_state.dart'
;
import
'theme_data.dart'
;
import
'theme_data.dart'
;
...
@@ -116,6 +117,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -116,6 +117,7 @@ class ButtonStyle with Diagnosticable {
this
.
animationDuration
,
this
.
animationDuration
,
this
.
enableFeedback
,
this
.
enableFeedback
,
this
.
alignment
,
this
.
alignment
,
this
.
splashFactory
,
});
});
/// The style for a button's [Text] widget descendants.
/// The style for a button's [Text] widget descendants.
...
@@ -230,6 +232,21 @@ class ButtonStyle with Diagnosticable {
...
@@ -230,6 +232,21 @@ class ButtonStyle with Diagnosticable {
/// Always defaults to [Alignment.center].
/// Always defaults to [Alignment.center].
final
AlignmentGeometry
?
alignment
;
final
AlignmentGeometry
?
alignment
;
/// Creates the [InkWell] splash factory, which defines the appearance of
/// "ink" splashes that occur in response to taps.
///
/// Use [NoSplash.splashFactory] to defeat ink splash rendering. For example:
/// ```dart
/// ElevatedButton(
/// style: ElevatedButton.styleFrom(
/// splashFactory: NoSplash.splashFactory,
/// ),
/// onPressed: () { },
/// child: Text('No Splash'),
/// )
/// ```
final
InteractiveInkFeatureFactory
?
splashFactory
;
/// Returns a copy of this ButtonStyle with the given fields replaced with
/// Returns a copy of this ButtonStyle with the given fields replaced with
/// the new values.
/// the new values.
ButtonStyle
copyWith
({
ButtonStyle
copyWith
({
...
@@ -250,6 +267,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -250,6 +267,7 @@ class ButtonStyle with Diagnosticable {
Duration
?
animationDuration
,
Duration
?
animationDuration
,
bool
?
enableFeedback
,
bool
?
enableFeedback
,
AlignmentGeometry
?
alignment
,
AlignmentGeometry
?
alignment
,
InteractiveInkFeatureFactory
?
splashFactory
,
})
{
})
{
return
ButtonStyle
(
return
ButtonStyle
(
textStyle:
textStyle
??
this
.
textStyle
,
textStyle:
textStyle
??
this
.
textStyle
,
...
@@ -269,6 +287,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -269,6 +287,7 @@ class ButtonStyle with Diagnosticable {
animationDuration:
animationDuration
??
this
.
animationDuration
,
animationDuration:
animationDuration
??
this
.
animationDuration
,
enableFeedback:
enableFeedback
??
this
.
enableFeedback
,
enableFeedback:
enableFeedback
??
this
.
enableFeedback
,
alignment:
alignment
??
this
.
alignment
,
alignment:
alignment
??
this
.
alignment
,
splashFactory:
splashFactory
??
this
.
splashFactory
,
);
);
}
}
...
@@ -298,6 +317,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -298,6 +317,7 @@ class ButtonStyle with Diagnosticable {
animationDuration:
animationDuration
??
style
.
animationDuration
,
animationDuration:
animationDuration
??
style
.
animationDuration
,
enableFeedback:
enableFeedback
??
style
.
enableFeedback
,
enableFeedback:
enableFeedback
??
style
.
enableFeedback
,
alignment:
alignment
??
style
.
alignment
,
alignment:
alignment
??
style
.
alignment
,
splashFactory:
splashFactory
??
style
.
splashFactory
,
);
);
}
}
...
@@ -321,6 +341,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -321,6 +341,7 @@ class ButtonStyle with Diagnosticable {
animationDuration
,
animationDuration
,
enableFeedback
,
enableFeedback
,
alignment
,
alignment
,
splashFactory
,
);
);
}
}
...
@@ -347,7 +368,8 @@ class ButtonStyle with Diagnosticable {
...
@@ -347,7 +368,8 @@ class ButtonStyle with Diagnosticable {
&&
other
.
tapTargetSize
==
tapTargetSize
&&
other
.
tapTargetSize
==
tapTargetSize
&&
other
.
animationDuration
==
animationDuration
&&
other
.
animationDuration
==
animationDuration
&&
other
.
enableFeedback
==
enableFeedback
&&
other
.
enableFeedback
==
enableFeedback
&&
other
.
alignment
==
alignment
;
&&
other
.
alignment
==
alignment
&&
other
.
splashFactory
==
splashFactory
;
}
}
@override
@override
...
@@ -395,6 +417,7 @@ class ButtonStyle with Diagnosticable {
...
@@ -395,6 +417,7 @@ class ButtonStyle with Diagnosticable {
animationDuration:
t
<
0.5
?
a
?.
animationDuration
:
b
?.
animationDuration
,
animationDuration:
t
<
0.5
?
a
?.
animationDuration
:
b
?.
animationDuration
,
enableFeedback:
t
<
0.5
?
a
?.
enableFeedback
:
b
?.
enableFeedback
,
enableFeedback:
t
<
0.5
?
a
?.
enableFeedback
:
b
?.
enableFeedback
,
alignment:
AlignmentGeometry
.
lerp
(
a
?.
alignment
,
b
?.
alignment
,
t
),
alignment:
AlignmentGeometry
.
lerp
(
a
?.
alignment
,
b
?.
alignment
,
t
),
splashFactory:
t
<
0.5
?
a
?.
splashFactory
:
b
?.
splashFactory
,
);
);
}
}
...
...
packages/flutter/lib/src/material/button_style_button.dart
View file @
51dd5bf1
...
@@ -11,7 +11,6 @@ import 'package:flutter/widgets.dart';
...
@@ -11,7 +11,6 @@ import 'package:flutter/widgets.dart';
import
'button_style.dart'
;
import
'button_style.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'constants.dart'
;
import
'ink_ripple.dart'
;
import
'ink_well.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material.dart'
;
import
'material_state.dart'
;
import
'material_state.dart'
;
...
@@ -285,6 +284,7 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
...
@@ -285,6 +284,7 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
final
bool
?
resolvedEnableFeedback
=
effectiveValue
((
ButtonStyle
?
style
)
=>
style
?.
enableFeedback
);
final
bool
?
resolvedEnableFeedback
=
effectiveValue
((
ButtonStyle
?
style
)
=>
style
?.
enableFeedback
);
final
AlignmentGeometry
?
resolvedAlignment
=
effectiveValue
((
ButtonStyle
?
style
)
=>
style
?.
alignment
);
final
AlignmentGeometry
?
resolvedAlignment
=
effectiveValue
((
ButtonStyle
?
style
)
=>
style
?.
alignment
);
final
Offset
densityAdjustment
=
resolvedVisualDensity
!.
baseSizeAdjustment
;
final
Offset
densityAdjustment
=
resolvedVisualDensity
!.
baseSizeAdjustment
;
final
InteractiveInkFeatureFactory
?
resolvedSplashFactory
=
effectiveValue
((
ButtonStyle
?
style
)
=>
style
?.
splashFactory
);
BoxConstraints
effectiveConstraints
=
resolvedVisualDensity
.
effectiveConstraints
(
BoxConstraints
effectiveConstraints
=
resolvedVisualDensity
.
effectiveConstraints
(
BoxConstraints
(
BoxConstraints
(
...
@@ -370,7 +370,7 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
...
@@ -370,7 +370,7 @@ class _ButtonStyleState extends State<ButtonStyleButton> with TickerProviderStat
canRequestFocus:
widget
.
enabled
,
canRequestFocus:
widget
.
enabled
,
onFocusChange:
_handleFocusedChanged
,
onFocusChange:
_handleFocusedChanged
,
autofocus:
widget
.
autofocus
,
autofocus:
widget
.
autofocus
,
splashFactory:
InkRipple
.
s
plashFactory
,
splashFactory:
resolvedS
plashFactory
,
overlayColor:
overlayColor
,
overlayColor:
overlayColor
,
highlightColor:
Colors
.
transparent
,
highlightColor:
Colors
.
transparent
,
customBorder:
resolvedShape
,
customBorder:
resolvedShape
,
...
...
packages/flutter/lib/src/material/elevated_button.dart
View file @
51dd5bf1
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
import
'color_scheme.dart'
;
import
'color_scheme.dart'
;
import
'constants.dart'
;
import
'constants.dart'
;
import
'elevated_button_theme.dart'
;
import
'elevated_button_theme.dart'
;
import
'ink_ripple.dart'
;
import
'ink_well.dart'
;
import
'material_state.dart'
;
import
'material_state.dart'
;
import
'theme.dart'
;
import
'theme.dart'
;
import
'theme_data.dart'
;
import
'theme_data.dart'
;
...
@@ -149,6 +151,7 @@ class ElevatedButton extends ButtonStyleButton {
...
@@ -149,6 +151,7 @@ class ElevatedButton extends ButtonStyleButton {
Duration
?
animationDuration
,
Duration
?
animationDuration
,
bool
?
enableFeedback
,
bool
?
enableFeedback
,
AlignmentGeometry
?
alignment
,
AlignmentGeometry
?
alignment
,
InteractiveInkFeatureFactory
?
splashFactory
,
})
{
})
{
final
MaterialStateProperty
<
Color
?>?
backgroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
final
MaterialStateProperty
<
Color
?>?
backgroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
?
null
?
null
...
@@ -184,6 +187,7 @@ class ElevatedButton extends ButtonStyleButton {
...
@@ -184,6 +187,7 @@ class ElevatedButton extends ButtonStyleButton {
animationDuration:
animationDuration
,
animationDuration:
animationDuration
,
enableFeedback:
enableFeedback
,
enableFeedback:
enableFeedback
,
alignment:
alignment
,
alignment:
alignment
,
splashFactory:
splashFactory
,
);
);
}
}
...
@@ -244,6 +248,7 @@ class ElevatedButton extends ButtonStyleButton {
...
@@ -244,6 +248,7 @@ class ElevatedButton extends ButtonStyleButton {
/// * `animationDuration` - kThemeChangeDuration
/// * `animationDuration` - kThemeChangeDuration
/// * `enableFeedback` - true
/// * `enableFeedback` - true
/// * `alignment` - Alignment.center
/// * `alignment` - Alignment.center
/// * `splashFactory` - InkRipple.splashFactory
///
///
/// The default padding values for the [ElevatedButton.icon] factory are slightly different:
/// The default padding values for the [ElevatedButton.icon] factory are slightly different:
///
///
...
@@ -287,6 +292,7 @@ class ElevatedButton extends ButtonStyleButton {
...
@@ -287,6 +292,7 @@ class ElevatedButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
);
);
}
}
...
...
packages/flutter/lib/src/material/ink_ripple.dart
View file @
51dd5bf1
...
@@ -183,8 +183,8 @@ class InkRipple extends InteractiveInkFeature {
...
@@ -183,8 +183,8 @@ class InkRipple extends InteractiveInkFeature {
late
Animation
<
int
>
_fadeOut
;
late
Animation
<
int
>
_fadeOut
;
late
AnimationController
_fadeOutController
;
late
AnimationController
_fadeOutController
;
/// Used to specify this type of ink splash for an [InkWell], [InkResponse]
/// Used to specify this type of ink splash for an [InkWell], [InkResponse]
,
///
or material [Them
e].
///
material [Theme], or [ButtonStyl
e].
static
const
InteractiveInkFeatureFactory
splashFactory
=
_InkRippleFactory
();
static
const
InteractiveInkFeatureFactory
splashFactory
=
_InkRippleFactory
();
static
final
Animatable
<
double
>
_easeCurveTween
=
CurveTween
(
curve:
Curves
.
ease
);
static
final
Animatable
<
double
>
_easeCurveTween
=
CurveTween
(
curve:
Curves
.
ease
);
...
...
packages/flutter/lib/src/material/ink_splash.dart
View file @
51dd5bf1
...
@@ -166,8 +166,8 @@ class InkSplash extends InteractiveInkFeature {
...
@@ -166,8 +166,8 @@ class InkSplash extends InteractiveInkFeature {
late
Animation
<
int
>
_alpha
;
late
Animation
<
int
>
_alpha
;
AnimationController
?
_alphaController
;
AnimationController
?
_alphaController
;
/// Used to specify this type of ink splash for an [InkWell], [InkResponse]
/// Used to specify this type of ink splash for an [InkWell], [InkResponse]
,
///
or material [Them
e].
///
material [Theme], or [ButtonStyl
e].
static
const
InteractiveInkFeatureFactory
splashFactory
=
_InkSplashFactory
();
static
const
InteractiveInkFeatureFactory
splashFactory
=
_InkSplashFactory
();
@override
@override
...
...
packages/flutter/lib/src/material/no_splash.dart
0 → 100644
View file @
51dd5bf1
// Copyright 2014 The Flutter 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:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
class
_NoSplashFactory
extends
InteractiveInkFeatureFactory
{
const
_NoSplashFactory
();
@override
InteractiveInkFeature
create
({
required
MaterialInkController
controller
,
required
RenderBox
referenceBox
,
required
Offset
position
,
required
Color
color
,
required
TextDirection
textDirection
,
bool
containedInkWell
=
false
,
RectCallback
?
rectCallback
,
BorderRadius
?
borderRadius
,
ShapeBorder
?
customBorder
,
double
?
radius
,
VoidCallback
?
onRemoved
,
})
{
return
NoSplash
(
controller:
controller
,
referenceBox:
referenceBox
,
color:
color
);
}
}
/// An [InteractiveInkFeature] that doesn't paint a splash.
///
/// Use [NoSplash.splashFactory] to defeat the default ink splash drawn by
/// an [InkWell] or [ButtonStyle]. For example, to create an [ElevatedButton]
/// that does not draw the default "ripple" ink splash when it's tapped:
/// ```dart
/// ElevatedButton(
/// style: ElevatedButton.styleFrom(
/// splashFactory: NoSplash.splashFactory,
/// ),
/// onPressed: () { },
/// child: Text('No Splash'),
/// )
/// ```
class
NoSplash
extends
InteractiveInkFeature
{
/// Create an [InteractiveInkFeature] that doesn't paint a splash.
NoSplash
({
required
MaterialInkController
controller
,
required
RenderBox
referenceBox
,
required
Color
color
,
VoidCallback
?
onRemoved
,
})
:
super
(
controller:
controller
,
referenceBox:
referenceBox
,
color:
color
,
onRemoved:
onRemoved
);
/// Used to specify this type of ink splash for an [InkWell], [InkResponse]
/// material [Theme], or [ButtonStyle].
static
const
InteractiveInkFeatureFactory
splashFactory
=
_NoSplashFactory
();
@override
void
paintFeature
(
Canvas
canvas
,
Matrix4
transform
)
{
}
}
packages/flutter/lib/src/material/outlined_button.dart
View file @
51dd5bf1
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
import
'color_scheme.dart'
;
import
'color_scheme.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'constants.dart'
;
import
'ink_ripple.dart'
;
import
'ink_well.dart'
;
import
'material_state.dart'
;
import
'material_state.dart'
;
import
'outlined_button_theme.dart'
;
import
'outlined_button_theme.dart'
;
import
'theme.dart'
;
import
'theme.dart'
;
...
@@ -141,6 +143,7 @@ class OutlinedButton extends ButtonStyleButton {
...
@@ -141,6 +143,7 @@ class OutlinedButton extends ButtonStyleButton {
Duration
?
animationDuration
,
Duration
?
animationDuration
,
bool
?
enableFeedback
,
bool
?
enableFeedback
,
AlignmentGeometry
?
alignment
,
AlignmentGeometry
?
alignment
,
InteractiveInkFeatureFactory
?
splashFactory
,
})
{
})
{
final
MaterialStateProperty
<
Color
?>?
foregroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
final
MaterialStateProperty
<
Color
?>?
foregroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
?
null
?
null
...
@@ -170,6 +173,7 @@ class OutlinedButton extends ButtonStyleButton {
...
@@ -170,6 +173,7 @@ class OutlinedButton extends ButtonStyleButton {
animationDuration:
animationDuration
,
animationDuration:
animationDuration
,
enableFeedback:
enableFeedback
,
enableFeedback:
enableFeedback
,
alignment:
alignment
,
alignment:
alignment
,
splashFactory:
splashFactory
,
);
);
}
}
...
@@ -223,6 +227,7 @@ class OutlinedButton extends ButtonStyleButton {
...
@@ -223,6 +227,7 @@ class OutlinedButton extends ButtonStyleButton {
/// * `animationDuration` - kThemeChangeDuration
/// * `animationDuration` - kThemeChangeDuration
/// * `enableFeedback` - true
/// * `enableFeedback` - true
/// * `alignment` - Alignment.center
/// * `alignment` - Alignment.center
/// * `splashFactory` - InkRipple.splashFactory
@override
@override
ButtonStyle
defaultStyleOf
(
BuildContext
context
)
{
ButtonStyle
defaultStyleOf
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
...
@@ -256,6 +261,7 @@ class OutlinedButton extends ButtonStyleButton {
...
@@ -256,6 +261,7 @@ class OutlinedButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
);
);
}
}
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
51dd5bf1
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
...
@@ -14,6 +14,8 @@ import 'button_style_button.dart';
import
'color_scheme.dart'
;
import
'color_scheme.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'constants.dart'
;
import
'ink_ripple.dart'
;
import
'ink_well.dart'
;
import
'material_state.dart'
;
import
'material_state.dart'
;
import
'text_button_theme.dart'
;
import
'text_button_theme.dart'
;
import
'theme.dart'
;
import
'theme.dart'
;
...
@@ -147,6 +149,7 @@ class TextButton extends ButtonStyleButton {
...
@@ -147,6 +149,7 @@ class TextButton extends ButtonStyleButton {
Duration
?
animationDuration
,
Duration
?
animationDuration
,
bool
?
enableFeedback
,
bool
?
enableFeedback
,
AlignmentGeometry
?
alignment
,
AlignmentGeometry
?
alignment
,
InteractiveInkFeatureFactory
?
splashFactory
,
})
{
})
{
final
MaterialStateProperty
<
Color
?>?
foregroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
final
MaterialStateProperty
<
Color
?>?
foregroundColor
=
(
onSurface
==
null
&&
primary
==
null
)
?
null
?
null
...
@@ -176,6 +179,7 @@ class TextButton extends ButtonStyleButton {
...
@@ -176,6 +179,7 @@ class TextButton extends ButtonStyleButton {
animationDuration:
animationDuration
,
animationDuration:
animationDuration
,
enableFeedback:
enableFeedback
,
enableFeedback:
enableFeedback
,
alignment:
alignment
,
alignment:
alignment
,
splashFactory:
splashFactory
,
);
);
}
}
...
@@ -232,6 +236,7 @@ class TextButton extends ButtonStyleButton {
...
@@ -232,6 +236,7 @@ class TextButton extends ButtonStyleButton {
/// * `animationDuration` - kThemeChangeDuration
/// * `animationDuration` - kThemeChangeDuration
/// * `enableFeedback` - true
/// * `enableFeedback` - true
/// * `alignment` - Alignment.center
/// * `alignment` - Alignment.center
/// * `splashFactory` - InkRipple.splashFactory
///
///
/// The default padding values for the [TextButton.icon] factory are slightly different:
/// The default padding values for the [TextButton.icon] factory are slightly different:
///
///
...
@@ -274,6 +279,7 @@ class TextButton extends ButtonStyleButton {
...
@@ -274,6 +279,7 @@ class TextButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
);
);
}
}
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
51dd5bf1
...
@@ -1072,6 +1072,46 @@ void main() {
...
@@ -1072,6 +1072,46 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'wx200'
)).
height
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'wx200'
)).
height
,
200
);
});
});
testWidgets
(
'ElevatedButton with NoSplash splashFactory paints nothing'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
InteractiveInkFeatureFactory
?
splashFactory
})
{
return
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
splashFactory:
splashFactory
,
),
onPressed:
()
{
},
child:
const
Text
(
'test'
),
),
),
),
);
}
// NoSplash.splashFactory, no splash circles drawn
await
tester
.
pumpWidget
(
buildFrame
(
splashFactory:
NoSplash
.
splashFactory
));
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
// Default splashFactory (from Theme.of().splashFactory), one splash circle drawn.
await
tester
.
pumpWidget
(
buildFrame
());
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
1
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
});
}
}
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
packages/flutter/test/material/ink_splash_test.dart
View file @
51dd5bf1
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/21506.
// Regression test for https://github.com/flutter/flutter/issues/21506.
testWidgets
(
'InkSplash receives textDirection'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'InkSplash receives textDirection'
,
(
WidgetTester
tester
)
async
{
...
@@ -23,4 +25,44 @@ void main() {
...
@@ -23,4 +25,44 @@ void main() {
await
tester
.
pumpAndSettle
(
const
Duration
(
milliseconds:
30
));
await
tester
.
pumpAndSettle
(
const
Duration
(
milliseconds:
30
));
expect
(
tester
.
takeException
(),
isNull
);
expect
(
tester
.
takeException
(),
isNull
);
});
});
testWidgets
(
'InkWell with NoSplash splashFactory paints nothing'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
InteractiveInkFeatureFactory
?
splashFactory
})
{
return
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
Material
(
child:
InkWell
(
splashFactory:
splashFactory
,
onTap:
()
{
},
child:
const
Text
(
'test'
),
),
),
),
),
);
}
// NoSplash.splashFactory, no splash circles drawn
await
tester
.
pumpWidget
(
buildFrame
(
splashFactory:
NoSplash
.
splashFactory
));
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
// Default splashFactory (from Theme.of().splashFactory), one splash circle drawn.
await
tester
.
pumpWidget
(
buildFrame
());
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
1
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
});
}
}
packages/flutter/test/material/outlined_button_test.dart
View file @
51dd5bf1
...
@@ -1248,6 +1248,46 @@ void main() {
...
@@ -1248,6 +1248,46 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'wx200'
)).
height
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'wx200'
)).
height
,
200
);
});
});
testWidgets
(
'OutlinedButton with NoSplash splashFactory paints nothing'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
InteractiveInkFeatureFactory
?
splashFactory
})
{
return
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
OutlinedButton
(
style:
OutlinedButton
.
styleFrom
(
splashFactory:
splashFactory
,
),
onPressed:
()
{
},
child:
const
Text
(
'test'
),
),
),
),
);
}
// NoSplash.splashFactory, no splash circles drawn
await
tester
.
pumpWidget
(
buildFrame
(
splashFactory:
NoSplash
.
splashFactory
));
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
// Default splashFactory (from Theme.of().splashFactory), one splash circle drawn.
await
tester
.
pumpWidget
(
buildFrame
());
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
1
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
});
}
}
PhysicalModelLayer
_findPhysicalLayer
(
Element
element
)
{
PhysicalModelLayer
_findPhysicalLayer
(
Element
element
)
{
...
...
packages/flutter/test/material/text_button_test.dart
View file @
51dd5bf1
...
@@ -1044,6 +1044,46 @@ void main() {
...
@@ -1044,6 +1044,46 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
TextButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
TextButton
,
'200xh'
)).
width
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
TextButton
,
'wx200'
)).
height
,
200
);
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
TextButton
,
'wx200'
)).
height
,
200
);
});
});
testWidgets
(
'TextButton with NoSplash splashFactory paints nothing'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
InteractiveInkFeatureFactory
?
splashFactory
})
{
return
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
TextButton
(
style:
TextButton
.
styleFrom
(
splashFactory:
splashFactory
,
),
onPressed:
()
{
},
child:
const
Text
(
'test'
),
),
),
),
);
}
// NoSplash.splashFactory, no splash circles drawn
await
tester
.
pumpWidget
(
buildFrame
(
splashFactory:
NoSplash
.
splashFactory
));
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
0
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
// Default splashFactory (from Theme.of().splashFactory), one splash circle drawn.
await
tester
.
pumpWidget
(
buildFrame
());
{
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'test'
)));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
text
(
'test'
)))!;
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
material
,
paintsExactlyCountTimes
(
#drawCircle
,
1
));
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
}
});
}
}
TextStyle
?
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
TextStyle
?
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
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