main.dart 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. ///
  2. /// Spine Runtimes License Agreement
  3. /// Last updated July 28, 2023. Replaces all prior versions.
  4. ///
  5. /// Copyright (c) 2013-2023, Esoteric Software LLC
  6. ///
  7. /// Integration of the Spine Runtimes into software or otherwise creating
  8. /// derivative works of the Spine Runtimes is permitted under the terms and
  9. /// conditions of Section 2 of the Spine Editor License Agreement:
  10. /// http://esotericsoftware.com/spine-editor-license
  11. ///
  12. /// Otherwise, it is permitted to integrate the Spine Runtimes into software or
  13. /// otherwise create derivative works of the Spine Runtimes (collectively,
  14. /// "Products"), provided that each user of the Products must obtain their own
  15. /// Spine Editor license and redistribution of the Products in any form must
  16. /// include this license and copyright notice.
  17. ///
  18. /// THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. /// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. /// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. /// DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. /// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. /// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. /// BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. /// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. /// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
  27. /// SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. ///
  29. import 'package:spine_flutter/spine_flutter.dart';
  30. import 'package:flutter/material.dart';
  31. import 'package:spine_flutter_example/debug_rendering.dart';
  32. import 'animation_state_events.dart';
  33. import 'dress_up.dart';
  34. import 'flame_example.dart';
  35. import 'ik_following.dart';
  36. import 'pause_play_animation.dart';
  37. import 'physics.dart';
  38. import 'simple_animation.dart';
  39. class ExampleSelector extends StatelessWidget {
  40. const ExampleSelector({super.key});
  41. @override
  42. Widget build(BuildContext context) {
  43. const spacer = SizedBox(height: 10);
  44. return Scaffold(
  45. appBar: AppBar(title: const Text('Spine Examples')),
  46. body: Center(
  47. child: Column(mainAxisSize: MainAxisSize.min, children: [
  48. ElevatedButton(
  49. child: const Text('Simple Animation'),
  50. onPressed: () {
  51. Navigator.push(
  52. context,
  53. MaterialPageRoute<void>(
  54. builder: (context) => const SimpleAnimation(),
  55. ),
  56. );
  57. },
  58. ),
  59. spacer,
  60. ElevatedButton(
  61. child: const Text('Pause/Play animation'),
  62. onPressed: () {
  63. Navigator.push(
  64. context,
  65. MaterialPageRoute<void>(
  66. builder: (context) => const PlayPauseAnimation(),
  67. ),
  68. );
  69. },
  70. ),
  71. spacer,
  72. ElevatedButton(
  73. child: const Text('Animation State Listener'),
  74. onPressed: () {
  75. Navigator.push(
  76. context,
  77. MaterialPageRoute<void>(
  78. builder: (context) => const AnimationStateEvents(),
  79. ),
  80. );
  81. },
  82. ),
  83. spacer,
  84. ElevatedButton(
  85. child: const Text('Debug Rendering'),
  86. onPressed: () {
  87. Navigator.push(
  88. context,
  89. MaterialPageRoute<void>(
  90. builder: (context) => const DebugRendering(),
  91. ),
  92. );
  93. },
  94. ),
  95. spacer,
  96. ElevatedButton(
  97. child: const Text('Dress Up'),
  98. onPressed: () {
  99. Navigator.push(
  100. context,
  101. MaterialPageRoute<void>(
  102. builder: (context) => const DressUp(),
  103. ),
  104. );
  105. },
  106. ),
  107. spacer,
  108. ElevatedButton(
  109. child: const Text('IK Following'),
  110. onPressed: () {
  111. Navigator.push(
  112. context,
  113. MaterialPageRoute<void>(
  114. builder: (context) => const IkFollowing(),
  115. ),
  116. );
  117. },
  118. ),
  119. spacer,
  120. ElevatedButton(
  121. child: const Text('Physics'),
  122. onPressed: () {
  123. Navigator.push(
  124. context,
  125. MaterialPageRoute<void>(
  126. builder: (context) => const PhysicsTest(),
  127. ),
  128. );
  129. },
  130. ),
  131. spacer,
  132. ElevatedButton(
  133. child: const Text('Flame: Simple Example'),
  134. onPressed: () {
  135. Navigator.push(
  136. context,
  137. MaterialPageRoute<void>(
  138. builder: (context) => SpineFlameGameWidget(SimpleFlameExample()),
  139. ),
  140. );
  141. },
  142. ),
  143. spacer,
  144. ElevatedButton(
  145. child: const Text('Flame: Pre-load and share Spine data'),
  146. onPressed: () {
  147. Navigator.push(
  148. context,
  149. MaterialPageRoute<void>(
  150. builder: (context) => SpineFlameGameWidget(PreloadAndShareSpineDataExample()),
  151. ),
  152. );
  153. },
  154. ),
  155. spacer,
  156. ElevatedButton(
  157. child: const Text('Flame: Dragon Example'),
  158. onPressed: () {
  159. Navigator.push(
  160. context,
  161. MaterialPageRoute<void>(
  162. builder: (context) => SpineFlameGameWidget(DragonExample()),
  163. ),
  164. );
  165. },
  166. ),
  167. spacer,
  168. ])));
  169. }
  170. }
  171. void main() async {
  172. WidgetsFlutterBinding.ensureInitialized();
  173. await initSpineFlutter(enableMemoryDebugging: false);
  174. runApp(const MaterialApp(title: "Spine Examples", home: ExampleSelector()));
  175. }