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
120d25f7
Unverified
Commit
120d25f7
authored
Jan 28, 2022
by
Taha Tesser
Committed by
GitHub
Jan 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`RefreshIndicator`: Add an interactive example (#97254)
parent
4e94eeab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
0 deletions
+115
-0
refresh_indicator.0.dart
...i/lib/material/refresh_indicator/refresh_indicator.0.dart
+74
-0
refresh_indicator.0_test.dart
.../material/refresh_indicator/refresh_indicator.0_test.dart
+35
-0
refresh_indicator.dart
packages/flutter/lib/src/material/refresh_indicator.dart
+6
-0
No files found.
examples/api/lib/material/refresh_indicator/refresh_indicator.0.dart
0 → 100644
View file @
120d25f7
// 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.
// Flutter code sample for RefreshIndicator
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'RefreshIndicator Sample'
;
@override
Widget
build
(
BuildContext
context
)
{
return
const
MaterialApp
(
title:
_title
,
home:
RefreshIndicatorExample
(
title:
_title
),
);
}
}
class
RefreshIndicatorExample
extends
StatefulWidget
{
const
RefreshIndicatorExample
({
Key
?
key
,
required
this
.
title
})
:
super
(
key:
key
);
final
String
title
;
@override
State
<
RefreshIndicatorExample
>
createState
()
=>
_RefreshIndicatorExampleState
();
}
class
_RefreshIndicatorExampleState
extends
State
<
RefreshIndicatorExample
>
{
final
GlobalKey
<
RefreshIndicatorState
>
_refreshIndicatorKey
=
GlobalKey
<
RefreshIndicatorState
>();
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
widget
.
title
),
),
body:
RefreshIndicator
(
key:
_refreshIndicatorKey
,
color:
Colors
.
white
,
backgroundColor:
Colors
.
blue
,
strokeWidth:
4.0
,
onRefresh:
()
async
{
// Replace this delay with the code to be executed during refresh
// and return a Future when code finishs execution.
return
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
3
));
},
// Pull from top to show refresh indicator.
child:
ListView
.
builder
(
itemCount:
25
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ListTile
(
title:
Text
(
'Item
$index
'
),
);
},
),
),
floatingActionButton:
FloatingActionButton
.
extended
(
onPressed:
()
{
// Show refresh indicator programmatically on button tap.
_refreshIndicatorKey
.
currentState
?.
show
();
},
icon:
const
Icon
(
Icons
.
refresh
),
label:
const
Text
(
'Show Indicator'
),
),
);
}
}
examples/api/test/material/refresh_indicator/refresh_indicator.0_test.dart
0 → 100644
View file @
120d25f7
// 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/material.dart'
;
import
'package:flutter_api_samples/material/refresh_indicator/refresh_indicator.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Trigger RefreshIndicator - Pull from top'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
await
tester
.
fling
(
find
.
text
(
'Item 1'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
getCenter
(
find
.
byType
(
RefreshProgressIndicator
)).
dy
,
lessThan
(
300.0
));
await
tester
.
pumpAndSettle
();
// Advance pending time
});
testWidgets
(
'Trigger RefreshIndicator - Button'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
getCenter
(
find
.
byType
(
RefreshProgressIndicator
)).
dy
,
lessThan
(
300.0
));
await
tester
.
pumpAndSettle
();
// Advance pending time
});
}
packages/flutter/lib/src/material/refresh_indicator.dart
View file @
120d25f7
...
...
@@ -71,6 +71,12 @@ enum RefreshIndicatorTriggerMode {
///
/// The trigger mode is configured by [RefreshIndicator.triggerMode].
///
/// {@tool dartpad}
/// This example shows how [RefreshIndicator] can be triggered in different ways.
///
/// ** See code in examples/api/lib/material/refresh_indicator/refresh_indicator.0.dart **
/// {@end-tool}
///
/// ## Troubleshooting
///
/// ### Refresh indicator does not show up
...
...
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