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
7f75d241
Unverified
Commit
7f75d241
authored
Oct 25, 2022
by
Taha Tesser
Committed by
GitHub
Oct 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Material 3 `ProgressIndicator` examples (#113950)
parent
b0e7c9c4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
340 additions
and
27 deletions
+340
-27
circular_progress_indicator.0.dart
...ial/progress_indicator/circular_progress_indicator.0.dart
+10
-13
circular_progress_indicator.1.dart
...ial/progress_indicator/circular_progress_indicator.1.dart
+101
-0
linear_progress_indicator.0.dart
...erial/progress_indicator/linear_progress_indicator.0.dart
+10
-13
linear_progress_indicator.1.dart
...erial/progress_indicator/linear_progress_indicator.1.dart
+101
-0
circular_progress_indicator.0_test.dart
...rogress_indicator/circular_progress_indicator.0_test.dart
+6
-1
circular_progress_indicator.1_test.dart
...rogress_indicator/circular_progress_indicator.1_test.dart
+36
-0
linear_progress_indicator.0_test.dart
.../progress_indicator/linear_progress_indicator.0_test.dart
+24
-0
linear_progress_indicator.1_test.dart
.../progress_indicator/linear_progress_indicator.1_test.dart
+36
-0
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+16
-0
No files found.
examples/api/lib/material/progress_indicator/circular_progress_indicator.0.dart
View file @
7f75d241
...
@@ -6,38 +6,35 @@
...
@@ -6,38 +6,35 @@
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
ProgressIndicator
App
());
class
MyApp
extends
StatelessWidget
{
class
ProgressIndicatorApp
extends
StatelessWidget
{
const
MyApp
({
super
.
key
});
const
ProgressIndicatorApp
({
super
.
key
});
static
const
String
_title
=
'Flutter Code Sample'
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
const
MaterialApp
(
return
const
MaterialApp
(
title:
_title
,
home:
ProgressIndicatorExample
(),
home:
MyStatefulWidget
(),
);
);
}
}
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
class
ProgressIndicatorExample
extends
StatefulWidget
{
const
MyStatefulWidget
({
super
.
key
});
const
ProgressIndicatorExample
({
super
.
key
});
@override
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidget
State
();
State
<
ProgressIndicatorExample
>
createState
()
=>
_ProgressIndicatorExample
State
();
}
}
/// [AnimationController]s can be created with `vsync: this` because of
class
_ProgressIndicatorExampleState
extends
State
<
ProgressIndicatorExample
>
/// [TickerProviderStateMixin].
class
_MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
with
TickerProviderStateMixin
{
with
TickerProviderStateMixin
{
late
AnimationController
controller
;
late
AnimationController
controller
;
@override
@override
void
initState
()
{
void
initState
()
{
controller
=
AnimationController
(
controller
=
AnimationController
(
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
vsync:
this
,
vsync:
this
,
duration:
const
Duration
(
seconds:
5
),
duration:
const
Duration
(
seconds:
5
),
)..
addListener
(()
{
)..
addListener
(()
{
...
...
examples/api/lib/material/progress_indicator/circular_progress_indicator.1.dart
0 → 100644
View file @
7f75d241
// 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 [CircularProgressIndicator].
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
ProgressIndicatorApp
());
class
ProgressIndicatorApp
extends
StatelessWidget
{
const
ProgressIndicatorApp
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
,
colorSchemeSeed:
const
Color
(
0xff6750a4
)),
home:
const
ProgressIndicatorExample
(),
);
}
}
class
ProgressIndicatorExample
extends
StatefulWidget
{
const
ProgressIndicatorExample
({
super
.
key
});
@override
State
<
ProgressIndicatorExample
>
createState
()
=>
_ProgressIndicatorExampleState
();
}
class
_ProgressIndicatorExampleState
extends
State
<
ProgressIndicatorExample
>
with
TickerProviderStateMixin
{
late
AnimationController
controller
;
bool
determinate
=
false
;
@override
void
initState
()
{
controller
=
AnimationController
(
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
vsync:
this
,
duration:
const
Duration
(
seconds:
2
),
)..
addListener
(()
{
setState
(()
{});
});
controller
.
repeat
(
reverse:
true
);
super
.
initState
();
}
@override
void
dispose
()
{
controller
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
20.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Text
(
'Circular progress indicator'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
),
const
SizedBox
(
height:
30
),
CircularProgressIndicator
(
value:
controller
.
value
,
semanticsLabel:
'Circular progress indicator'
,
),
const
SizedBox
(
height:
10
),
Row
(
children:
<
Widget
>[
Expanded
(
child:
Text
(
'determinate Mode'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleSmall
,
),
),
Switch
(
value:
determinate
,
onChanged:
(
bool
value
)
{
setState
(()
{
determinate
=
value
;
if
(
determinate
)
{
controller
.
stop
();
}
else
{
controller
..
forward
(
from:
controller
.
value
)..
repeat
();
}
});
},
),
],
),
],
),
),
);
}
}
examples/api/lib/material/progress_indicator/linear_progress_indicator.0.dart
View file @
7f75d241
...
@@ -6,38 +6,35 @@
...
@@ -6,38 +6,35 @@
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
My
App
());
void
main
(
)
=>
runApp
(
const
ProgressIndicator
App
());
class
MyApp
extends
StatelessWidget
{
class
ProgressIndicatorApp
extends
StatelessWidget
{
const
MyApp
({
super
.
key
});
const
ProgressIndicatorApp
({
super
.
key
});
static
const
String
_title
=
'Flutter Code Sample'
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
const
MaterialApp
(
return
const
MaterialApp
(
title:
_title
,
home:
ProgressIndicatorExample
(),
home:
MyStatefulWidget
(),
);
);
}
}
}
}
class
MyStatefulWidget
extends
StatefulWidget
{
class
ProgressIndicatorExample
extends
StatefulWidget
{
const
MyStatefulWidget
({
super
.
key
});
const
ProgressIndicatorExample
({
super
.
key
});
@override
@override
State
<
MyStatefulWidget
>
createState
()
=>
_MyStatefulWidget
State
();
State
<
ProgressIndicatorExample
>
createState
()
=>
_ProgressIndicatorExample
State
();
}
}
/// [AnimationController]s can be created with `vsync: this` because of
class
_ProgressIndicatorExampleState
extends
State
<
ProgressIndicatorExample
>
/// [TickerProviderStateMixin].
class
_MyStatefulWidgetState
extends
State
<
MyStatefulWidget
>
with
TickerProviderStateMixin
{
with
TickerProviderStateMixin
{
late
AnimationController
controller
;
late
AnimationController
controller
;
@override
@override
void
initState
()
{
void
initState
()
{
controller
=
AnimationController
(
controller
=
AnimationController
(
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
vsync:
this
,
vsync:
this
,
duration:
const
Duration
(
seconds:
5
),
duration:
const
Duration
(
seconds:
5
),
)..
addListener
(()
{
)..
addListener
(()
{
...
...
examples/api/lib/material/progress_indicator/linear_progress_indicator.1.dart
0 → 100644
View file @
7f75d241
// 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 [LinearProgressIndicator].
import
'package:flutter/material.dart'
;
void
main
(
)
=>
runApp
(
const
ProgressIndicatorApp
());
class
ProgressIndicatorApp
extends
StatelessWidget
{
const
ProgressIndicatorApp
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
theme:
ThemeData
(
useMaterial3:
true
,
colorSchemeSeed:
const
Color
(
0xff6750a4
)),
home:
const
ProgressIndicatorExample
(),
);
}
}
class
ProgressIndicatorExample
extends
StatefulWidget
{
const
ProgressIndicatorExample
({
super
.
key
});
@override
State
<
ProgressIndicatorExample
>
createState
()
=>
_ProgressIndicatorExampleState
();
}
class
_ProgressIndicatorExampleState
extends
State
<
ProgressIndicatorExample
>
with
TickerProviderStateMixin
{
late
AnimationController
controller
;
bool
determinate
=
false
;
@override
void
initState
()
{
controller
=
AnimationController
(
/// [AnimationController]s can be created with `vsync: this` because of
/// [TickerProviderStateMixin].
vsync:
this
,
duration:
const
Duration
(
seconds:
2
),
)..
addListener
(()
{
setState
(()
{});
});
controller
.
repeat
();
super
.
initState
();
}
@override
void
dispose
()
{
controller
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
20.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
const
Text
(
'Linear progress indicator'
,
style:
TextStyle
(
fontSize:
20
),
),
const
SizedBox
(
height:
30
),
LinearProgressIndicator
(
value:
controller
.
value
,
semanticsLabel:
'Linear progress indicator'
,
),
const
SizedBox
(
height:
10
),
Row
(
children:
<
Widget
>[
Expanded
(
child:
Text
(
'determinate Mode'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleSmall
,
),
),
Switch
(
value:
determinate
,
onChanged:
(
bool
value
)
{
setState
(()
{
determinate
=
value
;
if
(
determinate
)
{
controller
.
stop
();
}
else
{
controller
..
forward
(
from:
controller
.
value
)..
repeat
();
}
});
},
),
],
),
],
),
),
);
}
}
examples/api/test/material/progress_indicator/circular_progress_indicator.0_test.dart
View file @
7f75d241
...
@@ -9,11 +9,16 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -9,11 +9,16 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Finds CircularProgressIndicator'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Finds CircularProgressIndicator'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
const
example
.
My
App
(),
const
example
.
ProgressIndicator
App
(),
);
);
expect
(
expect
(
find
.
bySemanticsLabel
(
'Circular progress indicator'
),
find
.
bySemanticsLabel
(
'Circular progress indicator'
),
findsOneWidget
,
findsOneWidget
,
);
);
// Test if CircularProgressIndicator is animating.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
});
});
}
}
examples/api/test/material/progress_indicator/circular_progress_indicator.1_test.dart
0 → 100644
View file @
7f75d241
// 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/progress_indicator/circular_progress_indicator.1.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Finds CircularProgressIndicator'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
ProgressIndicatorApp
(),
);
expect
(
find
.
bySemanticsLabel
(
'Circular progress indicator'
).
first
,
findsOneWidget
,
);
// Test if CircularProgressIndicator is animating.
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
// Test determinate mode button.
await
tester
.
tap
(
find
.
byType
(
Switch
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
hasRunningAnimations
,
isFalse
);
await
tester
.
tap
(
find
.
byType
(
Switch
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
});
}
examples/api/test/material/progress_indicator/linear_progress_indicator.0_test.dart
0 → 100644
View file @
7f75d241
// 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_api_samples/material/progress_indicator/linear_progress_indicator.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Finds LinearProgressIndicator'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
ProgressIndicatorApp
(),
);
expect
(
find
.
bySemanticsLabel
(
'Linear progress indicator'
),
findsOneWidget
,
);
// Test if LinearProgressIndicator is animating.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
});
}
examples/api/test/material/progress_indicator/linear_progress_indicator.1_test.dart
0 → 100644
View file @
7f75d241
// 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/progress_indicator/linear_progress_indicator.1.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Finds LinearProgressIndicator'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
ProgressIndicatorApp
(),
);
expect
(
find
.
bySemanticsLabel
(
'Linear progress indicator'
).
first
,
findsOneWidget
,
);
// Test if LinearProgressIndicator is animating.
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
// Test determinate mode button.
await
tester
.
tap
(
find
.
byType
(
Switch
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
hasRunningAnimations
,
isFalse
);
await
tester
.
tap
(
find
.
byType
(
Switch
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
tester
.
hasRunningAnimations
,
isTrue
);
});
}
packages/flutter/lib/src/material/progress_indicator.dart
View file @
7f75d241
...
@@ -254,6 +254,14 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
...
@@ -254,6 +254,14 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
/// ** See code in examples/api/lib/material/progress_indicator/linear_progress_indicator.0.dart **
/// ** See code in examples/api/lib/material/progress_indicator/linear_progress_indicator.0.dart **
/// {@end-tool}
/// {@end-tool}
///
///
/// {@tool dartpad}
/// This sample shows the creation of a [LinearProgressIndicator] with a changing value.
/// When toggling the switch, [LinearProgressIndicator] uses a determinate value.
/// As described in: https://m3.material.io/components/progress-indicators/overview
///
/// ** See code in examples/api/lib/material/progress_indicator/linear_progress_indicator.1.dart **
/// {@end-tool}
///
/// See also:
/// See also:
///
///
/// * [CircularProgressIndicator], which shows progress along a circular arc.
/// * [CircularProgressIndicator], which shows progress along a circular arc.
...
@@ -474,6 +482,14 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
...
@@ -474,6 +482,14 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
/// ** See code in examples/api/lib/material/progress_indicator/circular_progress_indicator.0.dart **
/// ** See code in examples/api/lib/material/progress_indicator/circular_progress_indicator.0.dart **
/// {@end-tool}
/// {@end-tool}
///
///
/// {@tool dartpad}
/// This sample shows the creation of a [CircularProgressIndicator] with a changing value.
/// When toggling the switch, [CircularProgressIndicator] uses a determinate value.
/// As described in: https://m3.material.io/components/progress-indicators/overview
///
/// ** See code in examples/api/lib/material/progress_indicator/circular_progress_indicator.1.dart **
/// {@end-tool}
///
/// See also:
/// See also:
///
///
/// * [LinearProgressIndicator], which displays progress along a line.
/// * [LinearProgressIndicator], which displays progress along a line.
...
...
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