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
a8e6fd5b
Unverified
Commit
a8e6fd5b
authored
Mar 31, 2022
by
Darren Austin
Committed by
GitHub
Mar 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Material 3 common buttons should use sparkle splash effect on Android. (#101075)
parent
9da7317d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
160 additions
and
7 deletions
+160
-7
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+1
-1
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+1
-1
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+1
-1
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+4
-1
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+50
-0
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+51
-1
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+50
-0
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+2
-2
No files found.
packages/flutter/lib/src/material/elevated_button.dart
View file @
a8e6fd5b
...
...
@@ -306,7 +306,7 @@ class ElevatedButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
splashFactory:
theme
.
useMaterial3
?
theme
.
splashFactory
:
InkRipple
.
splashFactory
,
);
}
...
...
packages/flutter/lib/src/material/outlined_button.dart
View file @
a8e6fd5b
...
...
@@ -281,7 +281,7 @@ class OutlinedButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
splashFactory:
theme
.
useMaterial3
?
theme
.
splashFactory
:
InkRipple
.
splashFactory
,
);
}
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
a8e6fd5b
...
...
@@ -294,7 +294,7 @@ class TextButton extends ButtonStyleButton {
animationDuration:
kThemeChangeDuration
,
enableFeedback:
true
,
alignment:
Alignment
.
center
,
splashFactory:
InkRipple
.
splashFactory
,
splashFactory:
theme
.
useMaterial3
?
theme
.
splashFactory
:
InkRipple
.
splashFactory
,
);
}
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
a8e6fd5b
...
...
@@ -26,6 +26,7 @@ import 'drawer_theme.dart';
import
'elevated_button_theme.dart'
;
import
'expansion_tile_theme.dart'
;
import
'floating_action_button_theme.dart'
;
import
'ink_ripple.dart'
;
import
'ink_sparkle.dart'
;
import
'ink_splash.dart'
;
import
'ink_well.dart'
show
InteractiveInkFeatureFactory
;
...
...
@@ -446,7 +447,9 @@ class ThemeData with Diagnosticable {
visualDensity
??=
VisualDensity
.
adaptivePlatformDensity
;
useMaterial3
??=
false
;
final
bool
useInkSparkle
=
platform
==
TargetPlatform
.
android
&&
!
kIsWeb
;
splashFactory
??=
(
useMaterial3
&&
useInkSparkle
)
?
InkSparkle
.
splashFactory
:
InkSplash
.
splashFactory
;
splashFactory
??=
useMaterial3
?
useInkSparkle
?
InkSparkle
.
splashFactory
:
InkRipple
.
splashFactory
:
InkSplash
.
splashFactory
;
// COLOR
assert
(
colorScheme
?.
brightness
==
null
||
brightness
==
null
||
colorScheme
!.
brightness
==
brightness
);
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
a8e6fd5b
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -1272,6 +1273,55 @@ void main() {
}
});
testWidgets
(
'ElevatedButton uses InkSparkle only for Android non-web when useMaterial3 is true'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
true
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
ElevatedButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
ElevatedButton
),
matching:
find
.
byType
(
InkWell
),
));
if
(
debugDefaultTargetPlatformOverride
!
==
TargetPlatform
.
android
&&
!
kIsWeb
)
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkSparkle
.
splashFactory
));
}
else
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
}
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'ElevatedButton uses InkRipple when useMaterial3 is false'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
false
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
ElevatedButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
ElevatedButton
),
matching:
find
.
byType
(
InkWell
),
));
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'ElevatedButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
a8e6fd5b
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -1445,7 +1446,56 @@ void main() {
}
});
testWidgets
(
'OultinedButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'OutlinedButton uses InkSparkle only for Android non-web when useMaterial3 is true'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
true
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
OutlinedButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
OutlinedButton
),
matching:
find
.
byType
(
InkWell
),
));
if
(
debugDefaultTargetPlatformOverride
!
==
TargetPlatform
.
android
&&
!
kIsWeb
)
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkSparkle
.
splashFactory
));
}
else
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
}
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'OutlinedButton uses InkRipple when useMaterial3 is false'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
false
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
OutlinedButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
OutlinedButton
),
matching:
find
.
byType
(
InkWell
),
));
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'OutlinedButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
packages/flutter/test/material/text_button_test.dart
View file @
a8e6fd5b
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -1238,6 +1239,55 @@ void main() {
}
});
testWidgets
(
'TextButton uses InkSparkle only for Android non-web when useMaterial3 is true'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
true
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
TextButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
TextButton
),
matching:
find
.
byType
(
InkWell
),
));
if
(
debugDefaultTargetPlatformOverride
!
==
TargetPlatform
.
android
&&
!
kIsWeb
)
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkSparkle
.
splashFactory
));
}
else
{
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
}
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'TextButton uses InkRipple when useMaterial3 is false'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
false
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
theme
,
home:
Center
(
child:
TextButton
(
onPressed:
()
{
},
child:
const
Text
(
'button'
),
),
),
),
);
final
InkWell
buttonInkWell
=
tester
.
widget
<
InkWell
>(
find
.
descendant
(
of:
find
.
byType
(
TextButton
),
matching:
find
.
byType
(
InkWell
),
));
expect
(
buttonInkWell
.
splashFactory
,
equals
(
InkRipple
.
splashFactory
));
},
variant:
TargetPlatformVariant
.
all
());
testWidgets
(
'TextButton.icon does not overflow'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/77815
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
a8e6fd5b
...
...
@@ -333,7 +333,7 @@ void main() {
switch
(
debugDefaultTargetPlatformOverride
!)
{
case
TargetPlatform
.
android
:
if
(
kIsWeb
)
{
expect
(
theme
.
splashFactory
,
equals
(
Ink
Splash
.
splashFactory
));
expect
(
theme
.
splashFactory
,
equals
(
Ink
Ripple
.
splashFactory
));
}
else
{
expect
(
theme
.
splashFactory
,
equals
(
InkSparkle
.
splashFactory
));
}
...
...
@@ -343,7 +343,7 @@ void main() {
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
expect
(
theme
.
splashFactory
,
equals
(
Ink
Splash
.
splashFactory
));
expect
(
theme
.
splashFactory
,
equals
(
Ink
Ripple
.
splashFactory
));
}
},
variant:
TargetPlatformVariant
.
all
());
...
...
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