项目作者: spkersten

项目描述 :
PageView wrapper that supports Hero-like animations
高级语言: Dart
项目地址: git://github.com/spkersten/flutter_coast.git
创建时间: 2021-01-10T09:03:37Z
项目社区:https://github.com/spkersten/flutter_coast

开源协议:MIT License

下载


coast

build

PageView wrapper supporting Hero-like animations

img/example

Example

Create a Coast with a number of Beaches and add a CrabController as observer
to the Coast. Wrap a widget that you want to animate between beaches with a
Crab widget with the same tag.

  1. class CoastExampleApp extends StatefulWidget {
  2. @override
  3. _CoastExampleAppState createState() => _CoastExampleAppState();
  4. }
  5. class _CoastExampleAppState extends State<CoastExampleApp> {
  6. final _beaches = [
  7. Beach(builder: (context) => Cadzand()),
  8. Beach(builder: (context) => Westkapelle()),
  9. Beach(builder: (context) => Zoutelande()),
  10. ];
  11. final _coastController = CoastController();
  12. @override
  13. Widget build(BuildContext context) {
  14. return MaterialApp(
  15. home: Coast(
  16. beaches: _beaches,
  17. controller: _coastController,
  18. observers: [
  19. CrabController(),
  20. ],
  21. ),
  22. );
  23. }
  24. }
  25. class Cadzand extends StatelessWidget {
  26. @override
  27. Widget build(BuildContext context) => Scaffold(
  28. appBar: AppBar(
  29. title: Text("Cadzand"),
  30. backgroundColor: Colors.deepOrange,
  31. ),
  32. body: Stack(
  33. children: [
  34. Positioned(
  35. top: 40,
  36. left: 40,
  37. child: Crab(
  38. tag: "container",
  39. child: Container(
  40. color: Colors.green,
  41. width: 80,
  42. height: 60,
  43. ),
  44. ),
  45. ),
  46. ],
  47. ),
  48. );
  49. }
  50. class Westkapelle extends StatelessWidget {
  51. @override
  52. Widget build(BuildContext context) => Scaffold(
  53. appBar: AppBar(
  54. title: Text("Westkapelle"),
  55. backgroundColor: Colors.amber,
  56. ),
  57. body: Stack(
  58. children: [
  59. Positioned(
  60. top: 80,
  61. right: 40,
  62. child: Crab(
  63. tag: "container",
  64. child: Container(
  65. color: Colors.green,
  66. width: 200,
  67. height: 100,
  68. ),
  69. ),
  70. ),
  71. ],
  72. ),
  73. );
  74. }
  75. class Zoutelande extends StatelessWidget {
  76. @override
  77. Widget build(BuildContext context) => Scaffold(
  78. appBar: AppBar(
  79. title: Text("Zoutelande"),
  80. backgroundColor: Colors.deepPurple,
  81. ),
  82. body: Stack(
  83. children: [
  84. Positioned(
  85. bottom: 40,
  86. left: 20,
  87. child: Crab(
  88. tag: "container",
  89. child: Container(
  90. color: Colors.green,
  91. width: 100,
  92. height: 200,
  93. ),
  94. ),
  95. ),
  96. ],
  97. ),
  98. );
  99. }