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
81e693a7
Unverified
Commit
81e693a7
authored
Sep 24, 2019
by
Michael Goderbauer
Committed by
GitHub
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Sample code to SlideTransition (#41009)
parent
43932aa2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
README.md
dev/snippets/config/templates/README.md
+5
-0
stateful_widget_scaffold_center_freeform_state.tmpl
...lates/stateful_widget_scaffold_center_freeform_state.tmpl
+38
-0
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+45
-0
No files found.
dev/snippets/config/templates/README.md
View file @
81e693a7
...
...
@@ -101,6 +101,11 @@ follows:
`stateful_widget_scaffold`
, except that it wraps the stateful widget with a
`Scaffold`
_and_ a
`Center`
.
-
[
`stateful_widget_scaffold_center_freeform_state`
](
stateful_widget_scaffold_center_freeform_state.tmpl
)
:
Similar to
`stateful_widget_scaffold_center`
except that the code block has
to contain the entire state class defined as:
`class _MyStatefulWidgetState extends State<MyStatefulWidget>`
-
[
`stateless_widget_scaffold`
](
stateless_widget_scaffold.tmpl
)
: Similar to
`stateless_widget_material`
, except that it wraps the stateless widget with a
`Scaffold`
.
...
...
dev/snippets/config/templates/stateful_widget_scaffold_center_freeform_state.tmpl
0 → 100644
View file @
81e693a7
// Flutter code sample for {{id}}
{{description}}
import 'package:flutter/material.dart';
{{code-imports}}
void main() => runApp(new MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: Center(
child: MyStatefulWidget(),
),
),
);
}
}
{{code-preamble}}
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
{{code}}
packages/flutter/lib/src/widgets/transitions.dart
View file @
81e693a7
...
...
@@ -194,6 +194,51 @@ class _AnimatedState extends State<AnimatedWidget> {
/// animated by a [CurvedAnimation] set to [Curves.elasticIn]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/slide_transition.mp4}
///
/// {@tool snippet --template=stateful_widget_scaffold_center_freeform_state}
/// The following code implements the [SlideTransition] as seen in the video
/// above:
///
/// ```dart
/// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin {
/// AnimationController _controller;
/// Animation<Offset> _offsetAnimation;
///
/// @override
/// void initState() {
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 2),
/// vsync: this,
/// )..repeat(reverse: true);
/// _offsetAnimation = Tween<Offset>(
/// begin: Offset.zero,
/// end: const Offset(1.5, 0.0),
/// ).animate(CurvedAnimation(
/// parent: _controller,
/// curve: Curves.elasticIn,
/// ));
/// }
///
/// @override
/// void dispose() {
/// super.dispose();
/// _controller.dispose();
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return SlideTransition(
/// position: _offsetAnimation,
/// child: const Padding(
/// padding: EdgeInsets.all(8.0),
/// child: FlutterLogo(size: 150.0),
/// ),
/// );
/// }
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [AlignTransition], an animated version of an [Align] that animates its
...
...
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