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
bbc21fe3
Unverified
Commit
bbc21fe3
authored
Dec 13, 2021
by
Greg Spencer
Committed by
GitHub
Dec 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some issues with samples (#95044)
parent
77d6e960
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
47 deletions
+125
-47
README.md
dev/snippets/config/templates/README.md
+13
-2
mouse_cursor.0.dart
examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart
+48
-0
will_pop_scope.0.dart
...ples/api/lib/widgets/will_pop_scope/will_pop_scope.0.dart
+1
-1
mouse_cursor.0_test.dart
...s/api/test/services/mouse_cursor/mouse_cursor.0_test.dart
+21
-0
will_pop_scope.0_test.dart
...pi/test/widgets/will_pop_scope/will_pop_scope.0_test.dart
+32
-0
input_decorator.dart
packages/flutter/lib/src/material/input_decorator.dart
+2
-2
mouse_cursor.dart
packages/flutter/lib/src/services/mouse_cursor.dart
+2
-18
nested_scroll_view.dart
packages/flutter/lib/src/widgets/nested_scroll_view.dart
+3
-3
sliver_fill.dart
packages/flutter/lib/src/widgets/sliver_fill.dart
+1
-1
will_pop_scope.dart
packages/flutter/lib/src/widgets/will_pop_scope.dart
+2
-20
No files found.
dev/snippets/config/templates/README.md
View file @
bbc21fe3
## Templates are only used for Engine code samples.
They should not be used in the Framework, since the code samples should reside
in the
[
`examples/api`
](
../../../../examples/api
)
directory.
If you are creating engine code samples, the following document may be of
interest.
Eventually, Engine code samples will also be converted to point to separate
files as the framework does.
## Creating Code Snippets
## Creating Code Snippets
In general, creating application snippets can be accomplished with the following
In general, creating application snippets can be accomplished with the following
syntax inside
of
the dartdoc comment for a Flutter class/variable/enum/etc.:
syntax inside the dartdoc comment for a Flutter class/variable/enum/etc.:
```
dart
```
dart
/// {@tool snippet
--template=stateful_widget
}
/// {@tool snippet}
/// Any text outside of the code blocks will be accumulated and placed at the
/// Any text outside of the code blocks will be accumulated and placed at the
/// top of the snippet box as a description. Don't try and say "see the code
/// top of the snippet box as a description. Don't try and say "see the code
/// above" or "see the code below", since the location of the description may
/// above" or "see the code below", since the location of the description may
...
...
examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart
0 → 100644
View file @
bbc21fe3
// 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 MouseCursor
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
void
main
(
)
=>
runApp
(
const
MyApp
());
class
MyApp
extends
StatelessWidget
{
const
MyApp
({
Key
?
key
})
:
super
(
key:
key
);
static
const
String
_title
=
'MouseCursor Code Sample'
;
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
title:
_title
,
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
_title
)),
body:
const
MyStatelessWidget
(),
),
);
}
}
class
MyStatelessWidget
extends
StatelessWidget
{
const
MyStatelessWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
text
,
child:
Container
(
width:
200
,
height:
100
,
decoration:
BoxDecoration
(
color:
Colors
.
blue
,
border:
Border
.
all
(
color:
Colors
.
yellow
),
),
),
),
);
}
}
examples/api/lib/widgets/will_pop_scope/will_pop_scope.
1
.dart
→
examples/api/lib/widgets/will_pop_scope/will_pop_scope.
0
.dart
View file @
bbc21fe3
...
@@ -69,7 +69,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
...
@@ -69,7 +69,7 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
),
),
const
Text
(
'Push to a new screen, then tap on shouldPop '
const
Text
(
'Push to a new screen, then tap on shouldPop '
'button to toggle its value. Press the back '
'button to toggle its value. Press the back '
'button in the appBar to check its behavio
u
r '
'button in the appBar to check its behavior '
'for different values of shouldPop'
),
'for different values of shouldPop'
),
],
],
),
),
...
...
examples/api/test/services/mouse_cursor/mouse_cursor.0_test.dart
0 → 100644
View file @
bbc21fe3
// 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/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_api_samples/services/mouse_cursor/mouse_cursor.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'Uses Text Cursor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
expect
(
find
.
byType
(
MouseRegion
),
findsNWidgets
(
2
));
// There's one in the MaterialApp
final
Finder
mouseRegionFinder
=
find
.
ancestor
(
of:
find
.
byType
(
Container
),
matching:
find
.
byType
(
MouseRegion
));
expect
(
mouseRegionFinder
,
findsOneWidget
);
expect
((
tester
.
widget
(
mouseRegionFinder
)
as
MouseRegion
).
cursor
,
equals
(
SystemMouseCursors
.
text
));
});
}
examples/api/test/widgets/will_pop_scope/will_pop_scope.0_test.dart
0 → 100644
View file @
bbc21fe3
// 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/widgets/will_pop_scope/will_pop_scope.0.dart'
as
example
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'pressing shouldPop button changes shouldPop'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
final
Finder
buttonFinder
=
find
.
text
(
'shouldPop: true'
);
expect
(
buttonFinder
,
findsOneWidget
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pump
();
expect
(
find
.
text
(
'shouldPop: false'
),
findsOneWidget
);
});
testWidgets
(
'pressing Push button pushes route'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
example
.
MyApp
(),
);
final
Finder
buttonFinder
=
find
.
text
(
'Push'
);
expect
(
buttonFinder
,
findsOneWidget
);
expect
(
find
.
byType
(
example
.
MyStatefulWidget
),
findsOneWidget
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
example
.
MyStatefulWidget
,
skipOffstage:
false
),
findsNWidgets
(
2
));
});
}
packages/flutter/lib/src/material/input_decorator.dart
View file @
bbc21fe3
...
@@ -2397,7 +2397,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
...
@@ -2397,7 +2397,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// ** See code in examples/api/lib/material/input_decorator/input_decoration.3.dart **
/// ** See code in examples/api/lib/material/input_decorator/input_decoration.3.dart **
/// {@end-tool}
/// {@end-tool}
///
///
/// {@tool dartpad
--template=stateless_widget_scaffold
}
/// {@tool dartpad}
/// This sample shows how to style a `TextField` with a prefixIcon that changes color
/// This sample shows how to style a `TextField` with a prefixIcon that changes color
/// based on the `MaterialState`. The color defaults to gray, be blue while focused
/// based on the `MaterialState`. The color defaults to gray, be blue while focused
/// and red if in an error state.
/// and red if in an error state.
...
@@ -2405,7 +2405,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
...
@@ -2405,7 +2405,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
/// ** See code in examples/api/lib/material/input_decorator/input_decoration.material_state.0.dart **
/// ** See code in examples/api/lib/material/input_decorator/input_decoration.material_state.0.dart **
/// {@end-tool}
/// {@end-tool}
///
///
/// {@tool dartpad
--template=stateless_widget_scaffold
}
/// {@tool dartpad}
/// This sample shows how to style a `TextField` with a prefixIcon that changes color
/// This sample shows how to style a `TextField` with a prefixIcon that changes color
/// based on the `MaterialState` through the use of `ThemeData`. The color defaults
/// based on the `MaterialState` through the use of `ThemeData`. The color defaults
/// to gray, be blue while focused and red if in an error state.
/// to gray, be blue while focused and red if in an error state.
...
...
packages/flutter/lib/src/services/mouse_cursor.dart
View file @
bbc21fe3
...
@@ -160,28 +160,12 @@ abstract class MouseCursorSession {
...
@@ -160,28 +160,12 @@ abstract class MouseCursorSession {
/// another widget that exposes the [MouseRegion] API, such as
/// another widget that exposes the [MouseRegion] API, such as
/// [InkResponse.mouseCursor].
/// [InkResponse.mouseCursor].
///
///
/// {@tool
snippet --template=stateless_widget_material
}
/// {@tool
dartpad
}
/// This sample creates a rectangular region that is wrapped by a [MouseRegion]
/// This sample creates a rectangular region that is wrapped by a [MouseRegion]
/// with a system mouse cursor. The mouse pointer becomes an I-beam when
/// with a system mouse cursor. The mouse pointer becomes an I-beam when
/// hovering over the region.
/// hovering over the region.
///
///
/// ```dart
/// ** See code in examples/api/lib/services/mouse_cursor/mouse_cursor.0.dart **
/// Widget build(BuildContext context) {
/// return Center(
/// child: MouseRegion(
/// cursor: SystemMouseCursors.text,
/// child: Container(
/// width: 200,
/// height: 100,
/// decoration: BoxDecoration(
/// color: Colors.blue,
/// border: Border.all(color: Colors.yellow),
/// ),
/// ),
/// ),
/// );
/// }
/// ```
/// {@end-tool}
/// {@end-tool}
///
///
/// Assigning regions with mouse cursors on platforms that do not support mouse
/// Assigning regions with mouse cursors on platforms that do not support mouse
...
...
packages/flutter/lib/src/widgets/nested_scroll_view.dart
View file @
bbc21fe3
...
@@ -55,7 +55,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
...
@@ -55,7 +55,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
/// (those inside the [TabBarView], hooking them together so that they appear,
/// (those inside the [TabBarView], hooking them together so that they appear,
/// to the user, as one coherent scroll view.
/// to the user, as one coherent scroll view.
///
///
/// {@tool
sample
}
/// {@tool
dartpad
}
/// This example shows a [NestedScrollView] whose header is the combination of a
/// This example shows a [NestedScrollView] whose header is the combination of a
/// [TabBar] in a [SliverAppBar] and whose body is a [TabBarView]. It uses a
/// [TabBar] in a [SliverAppBar] and whose body is a [TabBarView]. It uses a
/// [SliverOverlapAbsorber]/[SliverOverlapInjector] pair to make the inner lists
/// [SliverOverlapAbsorber]/[SliverOverlapInjector] pair to make the inner lists
...
@@ -110,7 +110,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
...
@@ -110,7 +110,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
/// configuration, the flexible space of the app bar will open and collapse,
/// configuration, the flexible space of the app bar will open and collapse,
/// while the primary portion of the app bar remains pinned.
/// while the primary portion of the app bar remains pinned.
///
///
/// {@tool
sample
}
/// {@tool
dartpad
}
/// This simple example shows a [NestedScrollView] whose header contains a
/// This simple example shows a [NestedScrollView] whose header contains a
/// floating [SliverAppBar]. By using the [floatHeaderSlivers] property, the
/// floating [SliverAppBar]. By using the [floatHeaderSlivers] property, the
/// floating behavior is coordinated between the outer and inner [Scrollable]s,
/// floating behavior is coordinated between the outer and inner [Scrollable]s,
...
@@ -140,7 +140,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
...
@@ -140,7 +140,7 @@ typedef NestedScrollViewHeaderSliversBuilder = List<Widget> Function(BuildContex
/// for the nested "inner" scroll view below to end up under the [SliverAppBar]
/// for the nested "inner" scroll view below to end up under the [SliverAppBar]
/// even when the inner scroll view thinks it has not been scrolled.
/// even when the inner scroll view thinks it has not been scrolled.
///
///
/// {@tool
sample
}
/// {@tool
dartpad
}
/// This simple example shows a [NestedScrollView] whose header contains a
/// This simple example shows a [NestedScrollView] whose header contains a
/// snapping, floating [SliverAppBar]. _Without_ setting any additional flags,
/// snapping, floating [SliverAppBar]. _Without_ setting any additional flags,
/// e.g [NestedScrollView.floatHeaderSlivers], the [SliverAppBar] will animate
/// e.g [NestedScrollView.floatHeaderSlivers], the [SliverAppBar] will animate
...
...
packages/flutter/lib/src/widgets/sliver_fill.dart
View file @
bbc21fe3
...
@@ -239,7 +239,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding {
...
@@ -239,7 +239,7 @@ class _RenderSliverFractionalPadding extends RenderSliverEdgeInsetsPadding {
///
///
/// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_fill_overscroll.mp4}
/// {@animation 250 500 https://flutter.github.io/assets-for-api-docs/assets/widgets/sliver_fill_remaining_fill_overscroll.mp4}
///
///
/// {@tool
sample
}
/// {@tool
dartpad
}
/// In this sample the [SliverFillRemaining]'s child stretches to fill the
/// In this sample the [SliverFillRemaining]'s child stretches to fill the
/// overscroll area when [fillOverscroll] is true. This sample also features a
/// overscroll area when [fillOverscroll] is true. This sample also features a
/// button that is pinned to the bottom of the sliver, regardless of size or
/// button that is pinned to the bottom of the sliver, regardless of size or
...
...
packages/flutter/lib/src/widgets/will_pop_scope.dart
View file @
bbc21fe3
...
@@ -9,30 +9,12 @@ import 'routes.dart';
...
@@ -9,30 +9,12 @@ import 'routes.dart';
/// Registers a callback to veto attempts by the user to dismiss the enclosing
/// Registers a callback to veto attempts by the user to dismiss the enclosing
/// [ModalRoute].
/// [ModalRoute].
///
///
/// {@tool snippet --template=stateful_widget}
/// {@tool dartpad}
///
/// Whenever the back button is pressed, you will get a callback at [onWillPop],
/// Whenever the back button is pressed, you will get a callback at [onWillPop],
/// which returns a [Future]. If the [Future] returns true, the screen is
/// which returns a [Future]. If the [Future] returns true, the screen is
/// popped.
/// popped.
///
///
/// ```dart
/// ** See code in examples/api/lib/widgets/will_pop_scope/will_pop_scope.0.dart **
/// bool shouldPop = true;
/// @override
/// Widget build(BuildContext context) {
/// return WillPopScope (
/// onWillPop: () async {
/// return shouldPop;
/// },
/// child: const Text('WillPopScope sample'),
/// );
/// }
/// ```
/// {@end-tool}
///
/// {@tool dartpad}
///
///
/// ** See code in examples/api/lib/widgets/will_pop_scope/will_pop_scope.1.dart **
/// {@end-tool}
/// {@end-tool}
///
///
/// See also:
/// See also:
...
...
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