This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum _AniProps { width, height, color } | |
| class MyWidget extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| final _tween = MultiTween<_AniProps>() | |
| ..add(_AniProps.width, 200.0.tweenTo(300.0), 1.seconds) // <-- chain the | |
| ..add(_AniProps.width, 300.0.tweenTo(100.0), 1.seconds) // <-- width property | |
| ..add(_AniProps.height, 100.0.tweenTo(200.0), 2.seconds) | |
| ..add(_AniProps.color, Colors.green.tweenTo(Colors.orange), 2.seconds); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PlayAnimation<Color>( // <-- specify type of animated variable | |
| tween: Colors.red.tweenTo(Colors.blue), // <-- define tween of colors | |
| builder: (context, child, value) { // <-- builder function | |
| return Container( | |
| color: value, // <-- use animated value | |
| width: 100, | |
| height: 100 | |
| ); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| home: Scaffold( | |
| body: Center( | |
| child: ControlledAnimation( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DateSelection extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| var chunkedDays = DateTime.now() | |
| .until(6.days.fromNow()) | |
| .chunked(3, fill: () => null) | |
| .toList(); | |
| return Column( | |
| children: chunkedDays.map(buildRow).toList(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ascending order | |
| ["house", "cat", "pineapple"].sortedByNum((s) => s.length); | |
| ["house", "cat", "pineapple"].sortedByString((s) => s); | |
| // descending order | |
| ["house", "cat", "pineapple"].sortedByNum((s) => s.length).reversed; | |
| ["house", "cat", "pineapple"].sortedByString((s) => s).reversed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Persons extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| var persons = [ | |
| Person(name: "Jake", age: 21), | |
| Person(name: "Aaron", age: 48), | |
| Person(name: "Berry", age: 14), | |
| Person(name: "Kyle", age: 32), | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ["a", "b", "c", "d", "e"].chunked(3); // [ ["a", "b", "c"], ["d", "e"] ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var persons = [ | |
| Person(name: "John", age: 21), | |
| Person(name: "Carl", age: 18), | |
| Person(name: "Peter", age: 56), | |
| Person(name: "Sarah", age: 61) | |
| ]; | |
| persons.groupBy( | |
| (p) => p.age < 40 ? "young" : "old", | |
| valueTransform: (p) => p.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var persons = [ | |
| Person(age: 20), | |
| Person(age: 30), | |
| Person(age: 40) | |
| ]; | |
| persons.sumBy((p) => p.age); // 90 | |
| persons.averageBy((p) => p.age); // 30 | |
| persons.count((p) => p.age < 35); // 2 | |
| persons.minBy((a,b) => a.age.compareTo(b.age)); // Person(age: 20) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:simple_animations/simple_animations.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, |