main.dart 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 'simple_animation.dart';
  38. class ExampleSelector extends StatelessWidget {
  39. const ExampleSelector({super.key});
  40. @override
  41. Widget build(BuildContext context) {
  42. const spacer = SizedBox(height: 10);
  43. return Scaffold(
  44. appBar: AppBar(title: const Text('Spine Examples')),
  45. body: Center(
  46. child: Column(mainAxisSize: MainAxisSize.min, children: [
  47. ElevatedButton(
  48. child: const Text('Simple Animation'),
  49. onPressed: () {
  50. Navigator.push(
  51. context,
  52. MaterialPageRoute<void>(
  53. builder: (context) => const SimpleAnimation(),
  54. ),
  55. );
  56. },
  57. ),
  58. spacer,
  59. ElevatedButton(
  60. child: const Text('Pause/Play animation'),
  61. onPressed: () {
  62. Navigator.push(
  63. context,
  64. MaterialPageRoute<void>(
  65. builder: (context) => const PlayPauseAnimation(),
  66. ),
  67. );
  68. },
  69. ),
  70. spacer,
  71. ElevatedButton(
  72. child: const Text('Animation State Listener'),
  73. onPressed: () {
  74. Navigator.push(
  75. context,
  76. MaterialPageRoute<void>(
  77. builder: (context) => const AnimationStateEvents(),
  78. ),
  79. );
  80. },
  81. ),
  82. spacer,
  83. ElevatedButton(
  84. child: const Text('Debug Rendering'),
  85. onPressed: () {
  86. Navigator.push(
  87. context,
  88. MaterialPageRoute<void>(
  89. builder: (context) => const DebugRendering(),
  90. ),
  91. );
  92. },
  93. ),
  94. spacer,
  95. ElevatedButton(
  96. child: const Text('Dress Up'),
  97. onPressed: () {
  98. Navigator.push(
  99. context,
  100. MaterialPageRoute<void>(
  101. builder: (context) => const DressUp(),
  102. ),
  103. );
  104. },
  105. ),
  106. spacer,
  107. ElevatedButton(
  108. child: const Text('IK Following'),
  109. onPressed: () {
  110. Navigator.push(
  111. context,
  112. MaterialPageRoute<void>(
  113. builder: (context) => const IkFollowing(),
  114. ),
  115. );
  116. },
  117. ),
  118. spacer,
  119. ElevatedButton(
  120. child: const Text('Flame: Simple Example'),
  121. onPressed: () {
  122. Navigator.push(
  123. context,
  124. MaterialPageRoute<void>(
  125. builder: (context) => SpineFlameGameWidget(SimpleFlameExample()),
  126. ),
  127. );
  128. },
  129. ),
  130. spacer,
  131. ElevatedButton(
  132. child: const Text('Flame: Pre-load and share Spine data'),
  133. onPressed: () {
  134. Navigator.push(
  135. context,
  136. MaterialPageRoute<void>(
  137. builder: (context) => SpineFlameGameWidget(PreloadAndShareSpineDataExample()),
  138. ),
  139. );
  140. },
  141. ),
  142. spacer,
  143. ElevatedButton(
  144. child: const Text('Flame: Dragon Example'),
  145. onPressed: () {
  146. Navigator.push(
  147. context,
  148. MaterialPageRoute<void>(
  149. builder: (context) => SpineFlameGameWidget(DragonExample()),
  150. ),
  151. );
  152. },
  153. ),
  154. spacer,
  155. ])));
  156. }
  157. }
  158. void main() async {
  159. WidgetsFlutterBinding.ensureInitialized();
  160. await initSpineFlutter(enableMemoryDebugging: false);
  161. runApp(const MaterialApp(title: "Spine Examples", home: ExampleSelector()));
  162. }