-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add implicit animations codelab #3118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
58e88a6
9ae73c4
a759e76
a35344d
2131bb0
f2dedfd
b67d770
d089f12
90eb167
6f1426a
4f37b80
47f9459
d94950a
6919ef8
86a44c3
b59b688
1bfb7f8
5c62659
194052b
f7b87a1
7440311
1978a48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # markdown-spellcheck spelling configuration file | ||
| # Format - lines beginning # are comments | ||
| # global dictionary is at the start, file overrides afterwards | ||
| # one word per line, to define a file override use ' - filename' | ||
| # where filename is relative to this configuration file | ||
| codelab | ||
| stateful | ||
| DartPad | ||
| DartPads | ||
| ui | ||
| ImplicitlyAnimatedWidget | ||
| AnimatedOpacity | ||
| main.dart | ||
| AnimatedContainer | ||
| borderRadius | ||
| api | ||
| codelabs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import 'package:flutter_web/material.dart'; | ||
| import 'package:flutter_web_test/flutter_web_test.dart'; | ||
| import 'package:flutter_web_ui/ui.dart' as ui; | ||
| import 'dart:math'; | ||
|
||
|
|
||
| double randomBorderRadius() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| double randomMargin() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| Color randomColor() { | ||
| return Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF)); | ||
| } | ||
|
|
||
| class AnimatedContainerDemo extends StatelessWidget { | ||
| final color = randomColor(); | ||
|
||
| final borderRadius = randomBorderRadius(); | ||
| final margin = randomMargin(); | ||
|
|
||
| Widget build(BuildContext context) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add: |
||
| return Scaffold( | ||
| body: Center( | ||
| child: Column( | ||
| children: <Widget>[ | ||
| SizedBox( | ||
| width: 128, | ||
| height: 128, | ||
| child: Container( | ||
| margin: EdgeInsets.all(margin), | ||
| decoration: BoxDecoration( | ||
| color: color, | ||
| borderRadius: BorderRadius.circular(borderRadius), | ||
| ), | ||
| ), | ||
| ), | ||
| MaterialButton( | ||
| color: Theme.of(context).primaryColor, | ||
| child: Text( | ||
| 'change', | ||
| style: TextStyle(color: Colors.white), | ||
| ), | ||
| onPressed: () => null, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| debugShowCheckedModeBanner: false, | ||
| home: AnimatedContainerDemo(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Future<void> main() async { | ||
| await ui.webOnlyInitializePlatform(); | ||
| runApp(MyApp()); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import 'package:flutter_web/material.dart'; | ||
| import 'package:flutter_web_test/flutter_web_test.dart'; | ||
| import 'package:flutter_web_ui/ui.dart' as ui; | ||
| import 'dart:math'; | ||
|
|
||
| double randomBorderRadius() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| double randomMargin() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| Color randomColor() { | ||
| return Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF)); | ||
| } | ||
|
|
||
| class AnimatedContainerDemo extends StatefulWidget { | ||
| _AnimatedContainerDemoState createState() => _AnimatedContainerDemoState(); | ||
| } | ||
|
|
||
| class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> { | ||
| Color color; | ||
| double borderRadius; | ||
| double margin; | ||
|
|
||
| initState() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| final color = randomColor(); | ||
|
||
| final borderRadius = randomBorderRadius(); | ||
| final margin = randomMargin(); | ||
| } | ||
|
|
||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| body: Center( | ||
| child: Column( | ||
| children: <Widget>[ | ||
| SizedBox( | ||
| width: 128, | ||
| height: 128, | ||
| child: Container( | ||
| margin: EdgeInsets.all(margin), | ||
| decoration: BoxDecoration( | ||
| color: color, | ||
| borderRadius: BorderRadius.circular(borderRadius), | ||
| ), | ||
| ), | ||
| ), | ||
| MaterialButton( | ||
| color: Theme.of(context).primaryColor, | ||
| child: Text( | ||
| 'change', | ||
| style: TextStyle(color: Colors.white), | ||
| ), | ||
| onPressed: () => null, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| debugShowCheckedModeBanner: false, | ||
| home: AnimatedContainerDemo(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Future<void> main() async { | ||
| await ui.webOnlyInitializePlatform(); | ||
| runApp(MyApp()); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import 'package:flutter_web/material.dart'; | ||
| import 'package:flutter_web_test/flutter_web_test.dart'; | ||
| import 'package:flutter_web_ui/ui.dart' as ui; | ||
| import 'dart:math'; | ||
|
|
||
| const _duration = Duration(milliseconds: 400); | ||
|
|
||
| double randomBorderRadius() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| double randomMargin() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| Color randomColor() { | ||
| return Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF)); | ||
| } | ||
|
|
||
| class AnimatedContainerDemo extends StatefulWidget { | ||
| _AnimatedContainerDemoState createState() => _AnimatedContainerDemoState(); | ||
| } | ||
|
|
||
| class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> { | ||
| Color color; | ||
| double borderRadius; | ||
| double margin; | ||
|
|
||
| void initState() { | ||
| super.initState(); | ||
| color = Colors.deepPurple; | ||
| borderRadius = randomBorderRadius(); | ||
| margin = randomMargin(); | ||
| } | ||
|
|
||
| void change() { | ||
| setState(() { | ||
| color = randomColor(); | ||
| borderRadius = randomBorderRadius(); | ||
| margin = randomMargin(); | ||
| }); | ||
| } | ||
|
|
||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| body: Center( | ||
| child: Column( | ||
| children: <Widget>[ | ||
| SizedBox( | ||
| width: 128, | ||
| height: 128, | ||
| child: AnimatedContainer( | ||
| margin: EdgeInsets.all(margin), | ||
| decoration: BoxDecoration( | ||
| color: color, | ||
| borderRadius: BorderRadius.circular(borderRadius), | ||
| ), | ||
| duration: _duration, | ||
| ), | ||
| ), | ||
| MaterialButton( | ||
| color: Theme.of(context).primaryColor, | ||
| child: Text( | ||
| 'change', | ||
| style: TextStyle(color: Colors.white), | ||
| ), | ||
| onPressed: () => change(), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| debugShowCheckedModeBanner: false, | ||
| home: AnimatedContainerDemo(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Future<void> main() async { | ||
| await ui.webOnlyInitializePlatform(); | ||
| runApp(MyApp()); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import 'package:flutter_web/material.dart'; | ||
| import 'package:flutter_web_test/flutter_web_test.dart'; | ||
| import 'package:flutter_web_ui/ui.dart' as ui; | ||
| import 'dart:math'; | ||
|
|
||
| double randomBorderRadius() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| double randomMargin() { | ||
| return Random().nextDouble() * 64; | ||
| } | ||
|
|
||
| Color randomColor() { | ||
| return Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF)); | ||
| } | ||
|
|
||
| class AnimatedContainerDemo extends StatefulWidget { | ||
| _AnimatedContainerDemoState createState() => _AnimatedContainerDemoState(); | ||
| } | ||
|
|
||
| class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> { | ||
| Color color; | ||
| double borderRadius; | ||
| double margin; | ||
|
|
||
| initState() { | ||
| final color = randomColor(); | ||
| final borderRadius = randomBorderRadius(); | ||
| final margin = randomMargin(); | ||
| } | ||
|
|
||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| body: Center( | ||
| child: Column( | ||
| children: <Widget>[ | ||
| SizedBox( | ||
| width: 128, | ||
| height: 128, | ||
| child: AnimatedContainer( | ||
| margin: EdgeInsets.all(margin), | ||
| decoration: BoxDecoration( | ||
| color: color, | ||
| borderRadius: BorderRadius.circular(borderRadius), | ||
| ), | ||
| ), | ||
| ), | ||
| MaterialButton( | ||
| color: Theme.of(context).primaryColor, | ||
| child: Text( | ||
| 'change', | ||
| style: TextStyle(color: Colors.white), | ||
| ), | ||
| onPressed: () => null, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { | ||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| debugShowCheckedModeBanner: false, | ||
| home: AnimatedContainerDemo(), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Future<void> main() async { | ||
| await ui.webOnlyInitializePlatform(); | ||
| runApp(MyApp()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need license headers for all the .dart files?