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
5bc93402
Unverified
Commit
5bc93402
authored
Mar 21, 2022
by
Kate Lovett
Committed by
GitHub
Mar 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put stretch indicator behind m3 flag (#100234)
parent
e6bd2081
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
13 deletions
+82
-13
app.dart
packages/flutter/lib/src/material/app.dart
+14
-2
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+31
-10
overscroll_indicator.dart
packages/flutter/lib/src/widgets/overscroll_indicator.dart
+6
-0
scroll_configuration.dart
packages/flutter/lib/src/widgets/scroll_configuration.dart
+12
-0
app_test.dart
packages/flutter/test/material/app_test.dart
+18
-0
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+1
-1
No files found.
packages/flutter/lib/src/material/app.dart
View file @
5bc93402
...
...
@@ -730,7 +730,10 @@ class MaterialApp extends StatefulWidget {
/// [MaterialScrollBehavior.androidOverscrollIndicator] specifies the
/// overscroll indicator that is used on [TargetPlatform.android]. When null,
/// [ThemeData.androidOverscrollIndicator] is used. If also null, the default
/// overscroll indicator is the [GlowingOverscrollIndicator].
/// overscroll indicator is the [GlowingOverscrollIndicator]. These properties
/// are deprecated. In order to use the [StretchingOverscrollIndicator], use
/// the [ThemeData.useMaterial3] flag, or override
/// [ScrollBehavior.buildOverscrollIndicator].
///
/// See also:
///
...
...
@@ -745,6 +748,10 @@ class MaterialScrollBehavior extends ScrollBehavior {
/// [ThemeData.androidOverscrollIndicator] is used. If also null, the default
/// overscroll indicator is the [GlowingOverscrollIndicator].
const
MaterialScrollBehavior
({
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
})
:
_androidOverscrollIndicator
=
androidOverscrollIndicator
,
super
(
androidOverscrollIndicator:
androidOverscrollIndicator
);
...
...
@@ -782,9 +789,14 @@ class MaterialScrollBehavior extends ScrollBehavior {
Widget
buildOverscrollIndicator
(
BuildContext
context
,
Widget
child
,
ScrollableDetails
details
)
{
// When modifying this function, consider modifying the implementation in
// the base class as well.
final
AndroidOverscrollIndicator
indicator
=
_androidOverscrollIndicator
late
final
AndroidOverscrollIndicator
indicator
;
if
(
Theme
.
of
(
context
).
useMaterial3
)
{
indicator
=
AndroidOverscrollIndicator
.
stretch
;
}
else
{
indicator
=
_androidOverscrollIndicator
??
Theme
.
of
(
context
).
androidOverscrollIndicator
??
androidOverscrollIndicator
;
}
switch
(
getPlatform
(
context
))
{
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
linux
:
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
5bc93402
...
...
@@ -270,7 +270,6 @@ class ThemeData with Diagnosticable {
/// * [ColorScheme.fromSeed], which is used to create a [ColorScheme] from a seed color.
factory
ThemeData
({
// GENERAL CONFIGURATION
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
bool
?
applyElevationOverlayColor
,
NoDefaultCupertinoThemeData
?
cupertinoOverrideTheme
,
Iterable
<
ThemeExtension
<
dynamic
>>?
extensions
,
...
...
@@ -418,6 +417,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.6.0-11.0.pre.'
,
)
Brightness
?
primaryColorBrightness
,
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
})
{
// GENERAL CONFIGURATION
cupertinoOverrideTheme
=
cupertinoOverrideTheme
?.
noDefault
();
...
...
@@ -591,7 +595,6 @@ class ThemeData with Diagnosticable {
return
ThemeData
.
raw
(
// GENERAL CONFIGURATION
androidOverscrollIndicator:
androidOverscrollIndicator
,
applyElevationOverlayColor:
applyElevationOverlayColor
,
cupertinoOverrideTheme:
cupertinoOverrideTheme
,
extensions:
_themeExtensionIterableToMap
(
extensions
),
...
...
@@ -680,6 +683,7 @@ class ThemeData with Diagnosticable {
buttonColor:
buttonColor
,
fixTextFieldOutlineLabel:
fixTextFieldOutlineLabel
,
primaryColorBrightness:
primaryColorBrightness
,
androidOverscrollIndicator:
androidOverscrollIndicator
,
);
}
...
...
@@ -695,7 +699,6 @@ class ThemeData with Diagnosticable {
// operator == and in the Object.hash method and in the order of fields
// in this class, and in the lerp() method.
// GENERAL CONFIGURATION
required
this
.
androidOverscrollIndicator
,
required
this
.
applyElevationOverlayColor
,
required
this
.
cupertinoOverrideTheme
,
required
this
.
extensions
,
...
...
@@ -839,6 +842,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.6.0-11.0.pre.'
,
)
required
this
.
primaryColorBrightness
,
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
required
this
.
androidOverscrollIndicator
,
})
:
// GENERAL CONFIGURATION
assert
(
applyElevationOverlayColor
!=
null
),
assert
(
extensions
!=
null
),
...
...
@@ -1031,12 +1039,19 @@ class ThemeData with Diagnosticable {
/// [MaterialScrollBehavior.androidOverscrollIndicator] is
/// [AndroidOverscrollIndicator.glow].
///
/// This property is deprecated. Use the [useMaterial3] flag instead, or
/// override [ScrollBehavior.buildOverscrollIndicator].
///
/// See also:
///
/// * [StretchingOverscrollIndicator], a material design edge effect
/// that transforms the contents of a scrollable when overscrolled.
/// * [GlowingOverscrollIndicator], an edge effect that paints a glow
/// over the contents of a scrollable when overscrolled.
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
final
AndroidOverscrollIndicator
?
androidOverscrollIndicator
;
/// Apply a semi-transparent overlay color on Material surfaces to indicate
...
...
@@ -1239,6 +1254,8 @@ class ThemeData with Diagnosticable {
/// * [Material]
/// * [NavigationBar]
/// * [NavigationRail]
/// * [StretchingOverscrollIndicator], replacing the
/// [GlowingOverscrollIndicator]
///
/// See also:
///
...
...
@@ -1646,7 +1663,6 @@ class ThemeData with Diagnosticable {
/// The [brightness] value is applied to the [colorScheme].
ThemeData
copyWith
({
// GENERAL CONFIGURATION
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
bool
?
applyElevationOverlayColor
,
NoDefaultCupertinoThemeData
?
cupertinoOverrideTheme
,
Iterable
<
ThemeExtension
<
dynamic
>>?
extensions
,
...
...
@@ -1791,11 +1807,15 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v2.6.0-11.0.pre.'
,
)
Brightness
?
primaryColorBrightness
,
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
})
{
cupertinoOverrideTheme
=
cupertinoOverrideTheme
?.
noDefault
();
return
ThemeData
.
raw
(
// GENERAL CONFIGURATION
androidOverscrollIndicator:
androidOverscrollIndicator
??
this
.
androidOverscrollIndicator
,
applyElevationOverlayColor:
applyElevationOverlayColor
??
this
.
applyElevationOverlayColor
,
cupertinoOverrideTheme:
cupertinoOverrideTheme
??
this
.
cupertinoOverrideTheme
,
extensions:
(
extensions
!=
null
)
?
_themeExtensionIterableToMap
(
extensions
)
:
this
.
extensions
,
...
...
@@ -1884,6 +1904,7 @@ class ThemeData with Diagnosticable {
buttonColor:
buttonColor
??
this
.
buttonColor
,
fixTextFieldOutlineLabel:
fixTextFieldOutlineLabel
??
this
.
fixTextFieldOutlineLabel
,
primaryColorBrightness:
primaryColorBrightness
??
this
.
primaryColorBrightness
,
androidOverscrollIndicator:
androidOverscrollIndicator
??
this
.
androidOverscrollIndicator
,
);
}
...
...
@@ -1994,7 +2015,6 @@ class ThemeData with Diagnosticable {
// the class and in the lerp() method.
return
ThemeData
.
raw
(
// GENERAL CONFIGURATION
androidOverscrollIndicator:
t
<
0.5
?
a
.
androidOverscrollIndicator
:
b
.
androidOverscrollIndicator
,
applyElevationOverlayColor:
t
<
0.5
?
a
.
applyElevationOverlayColor
:
b
.
applyElevationOverlayColor
,
cupertinoOverrideTheme:
t
<
0.5
?
a
.
cupertinoOverrideTheme
:
b
.
cupertinoOverrideTheme
,
extensions:
_lerpThemeExtensions
(
a
,
b
,
t
),
...
...
@@ -2083,6 +2103,7 @@ class ThemeData with Diagnosticable {
buttonColor:
Color
.
lerp
(
a
.
buttonColor
,
b
.
buttonColor
,
t
)!,
fixTextFieldOutlineLabel:
t
<
0.5
?
a
.
fixTextFieldOutlineLabel
:
b
.
fixTextFieldOutlineLabel
,
primaryColorBrightness:
t
<
0.5
?
a
.
primaryColorBrightness
:
b
.
primaryColorBrightness
,
androidOverscrollIndicator:
t
<
0.5
?
a
.
androidOverscrollIndicator
:
b
.
androidOverscrollIndicator
,
);
}
...
...
@@ -2095,7 +2116,6 @@ class ThemeData with Diagnosticable {
// the class and in the lerp() method.
return
other
is
ThemeData
&&
// GENERAL CONFIGURATION
other
.
androidOverscrollIndicator
==
androidOverscrollIndicator
&&
other
.
applyElevationOverlayColor
==
applyElevationOverlayColor
&&
other
.
cupertinoOverrideTheme
==
cupertinoOverrideTheme
&&
mapEquals
(
other
.
extensions
,
extensions
)
&&
...
...
@@ -2183,7 +2203,8 @@ class ThemeData with Diagnosticable {
other
.
accentIconTheme
==
accentIconTheme
&&
other
.
buttonColor
==
buttonColor
&&
other
.
fixTextFieldOutlineLabel
==
fixTextFieldOutlineLabel
&&
other
.
primaryColorBrightness
==
primaryColorBrightness
;
other
.
primaryColorBrightness
==
primaryColorBrightness
&&
other
.
androidOverscrollIndicator
==
androidOverscrollIndicator
;
}
@override
...
...
@@ -2193,7 +2214,6 @@ class ThemeData with Diagnosticable {
// and in the order of fields in the class and in the lerp() method.
final
List
<
Object
?>
values
=
<
Object
?>[
// GENERAL CONFIGURATION
androidOverscrollIndicator
,
applyElevationOverlayColor
,
cupertinoOverrideTheme
,
hashList
(
extensions
.
keys
),
...
...
@@ -2283,6 +2303,7 @@ class ThemeData with Diagnosticable {
buttonColor
,
fixTextFieldOutlineLabel
,
primaryColorBrightness
,
androidOverscrollIndicator
,
];
return
Object
.
hashAll
(
values
);
}
...
...
@@ -2292,7 +2313,6 @@ class ThemeData with Diagnosticable {
super
.
debugFillProperties
(
properties
);
final
ThemeData
defaultData
=
ThemeData
.
fallback
();
// GENERAL CONFIGURATION
properties
.
add
(
EnumProperty
<
AndroidOverscrollIndicator
>(
'androidOverscrollIndicator'
,
androidOverscrollIndicator
,
defaultValue:
null
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'applyElevationOverlayColor'
,
applyElevationOverlayColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
NoDefaultCupertinoThemeData
>(
'cupertinoOverrideTheme'
,
cupertinoOverrideTheme
,
defaultValue:
defaultData
.
cupertinoOverrideTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
IterableProperty
<
ThemeExtension
<
dynamic
>>(
'extensions'
,
extensions
.
values
,
defaultValue:
defaultData
.
extensions
.
values
,
level:
DiagnosticLevel
.
debug
));
...
...
@@ -2381,6 +2401,7 @@ class ThemeData with Diagnosticable {
properties
.
add
(
ColorProperty
(
'buttonColor'
,
buttonColor
,
defaultValue:
defaultData
.
buttonColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'fixTextFieldOutlineLabel'
,
fixTextFieldOutlineLabel
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
Brightness
>(
'primaryColorBrightness'
,
primaryColorBrightness
,
defaultValue:
defaultData
.
primaryColorBrightness
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
AndroidOverscrollIndicator
>(
'androidOverscrollIndicator'
,
androidOverscrollIndicator
,
defaultValue:
null
,
level:
DiagnosticLevel
.
debug
));
}
}
...
...
packages/flutter/lib/src/widgets/overscroll_indicator.dart
View file @
5bc93402
...
...
@@ -623,6 +623,9 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter {
/// [ScrollBehavior.androidOverscrollIndicator] is
/// [AndroidOverscrollIndicator.stretch]. Otherwise, the default
/// [GlowingOverscrollIndicator] is applied.
/// [ScrollBehavior.androidOverscrollIndicator] is deprecated, use
/// [ThemeData.useMaterial3], or override
/// [ScrollBehavior.buildOverscrollIndicator] to choose the desired indicator.
///
/// See also:
///
...
...
@@ -669,6 +672,9 @@ class StretchingOverscrollIndicator extends StatefulWidget {
/// [ScrollBehavior.buildOverscrollIndicator] method when opted-in using the
/// [ScrollBehavior.androidOverscrollIndicator] flag. In this case
/// the child is usually the one provided as an argument to that method.
/// [ScrollBehavior.androidOverscrollIndicator] is deprecated, use
/// [ThemeData.useMaterial3], or override
/// [ScrollBehavior.buildOverscrollIndicator] to choose the desired indicator.
final
Widget
?
child
;
@override
...
...
packages/flutter/lib/src/widgets/scroll_configuration.dart
View file @
5bc93402
...
...
@@ -62,6 +62,10 @@ enum AndroidOverscrollIndicator {
class
ScrollBehavior
{
/// Creates a description of how [Scrollable] widgets should behave.
const
ScrollBehavior
({
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
}):
_androidOverscrollIndicator
=
androidOverscrollIndicator
;
...
...
@@ -73,6 +77,10 @@ class ScrollBehavior {
///
/// * [MaterialScrollBehavior], which supports setting this property
/// using [ThemeData].
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
get
androidOverscrollIndicator
=>
_androidOverscrollIndicator
??
_kDefaultAndroidOverscrollIndicator
;
final
AndroidOverscrollIndicator
?
_androidOverscrollIndicator
;
...
...
@@ -90,6 +98,10 @@ class ScrollBehavior {
Set
<
PointerDeviceKind
>?
dragDevices
,
ScrollPhysics
?
physics
,
TargetPlatform
?
platform
,
@Deprecated
(
'Use ThemeData.useMaterial3 or override ScrollBehavior.buildOverscrollIndicator. '
'This feature was deprecated after v2.13.0-0.0.pre.'
)
AndroidOverscrollIndicator
?
androidOverscrollIndicator
,
})
{
return
_WrappedScrollBehavior
(
...
...
packages/flutter/test/material/app_test.dart
View file @
5bc93402
...
...
@@ -1103,6 +1103,24 @@ void main() {
expect
(
find
.
byType
(
GlowingOverscrollIndicator
),
findsNothing
);
},
variant:
TargetPlatformVariant
.
only
(
TargetPlatform
.
android
));
testWidgets
(
'ScrollBehavior stretch android overscroll indicator via useMaterial3 flag'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
),
home:
ListView
(
children:
const
<
Widget
>[
SizedBox
(
height:
1000.0
,
width:
1000.0
,
child:
Text
(
'Test'
),
)
]
)
));
expect
(
find
.
byType
(
StretchingOverscrollIndicator
),
findsOneWidget
);
expect
(
find
.
byType
(
GlowingOverscrollIndicator
),
findsNothing
);
},
variant:
TargetPlatformVariant
.
only
(
TargetPlatform
.
android
));
testWidgets
(
'Overscroll indicator can be set by theme'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
// The current default is glowing, setting via the theme should override.
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
5bc93402
...
...
@@ -999,7 +999,6 @@ void main() {
// List of properties must match the properties in ThemeData.hashCode()
final
Set
<
String
>
expectedPropertyNames
=
<
String
>{
// GENERAL CONFIGURATION
'androidOverscrollIndicator'
,
'applyElevationOverlayColor'
,
'cupertinoOverrideTheme'
,
'extensions'
,
...
...
@@ -1088,6 +1087,7 @@ void main() {
'buttonColor'
,
'fixTextFieldOutlineLabel'
,
'primaryColorBrightness'
,
'androidOverscrollIndicator'
,
};
final
DiagnosticPropertiesBuilder
properties
=
DiagnosticPropertiesBuilder
();
...
...
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