main.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import 'package:spine_flutter/spine_flutter.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:spine_flutter_example/debug_rendering.dart';
  4. import 'animation_state_events.dart';
  5. import 'dress_up.dart';
  6. import 'flame_example.dart';
  7. import 'ik_following.dart';
  8. import 'pause_play_animation.dart';
  9. import 'simple_animation.dart';
  10. class ExampleSelector extends StatelessWidget {
  11. const ExampleSelector({super.key});
  12. @override
  13. Widget build(BuildContext context) {
  14. const spacer = SizedBox(height: 10);
  15. return Scaffold(
  16. appBar: AppBar(title: const Text('Spine Examples')),
  17. body: Center(
  18. child: Column(mainAxisSize: MainAxisSize.min, children: [
  19. ElevatedButton(
  20. child: const Text('Simple Animation'),
  21. onPressed: () {
  22. Navigator.push(
  23. context,
  24. MaterialPageRoute<void>(
  25. builder: (context) => const SimpleAnimation(),
  26. ),
  27. );
  28. },
  29. ),
  30. spacer,
  31. ElevatedButton(
  32. child: const Text('Pause/Play animation'),
  33. onPressed: () {
  34. Navigator.push(
  35. context,
  36. MaterialPageRoute<void>(
  37. builder: (context) => const PlayPauseAnimation(),
  38. ),
  39. );
  40. },
  41. ),
  42. spacer,
  43. ElevatedButton(
  44. child: const Text('Animation State Listener'),
  45. onPressed: () {
  46. Navigator.push(
  47. context,
  48. MaterialPageRoute<void>(
  49. builder: (context) => const AnimationStateEvents(),
  50. ),
  51. );
  52. },
  53. ),
  54. spacer,
  55. ElevatedButton(
  56. child: const Text('Debug Rendering'),
  57. onPressed: () {
  58. Navigator.push(
  59. context,
  60. MaterialPageRoute<void>(
  61. builder: (context) => const DebugRendering(),
  62. ),
  63. );
  64. },
  65. ),
  66. spacer,
  67. ElevatedButton(
  68. child: const Text('Dress Up'),
  69. onPressed: () {
  70. Navigator.push(
  71. context,
  72. MaterialPageRoute<void>(
  73. builder: (context) => const DressUp(),
  74. ),
  75. );
  76. },
  77. ),
  78. spacer,
  79. ElevatedButton(
  80. child: const Text('IK Following'),
  81. onPressed: () {
  82. Navigator.push(
  83. context,
  84. MaterialPageRoute<void>(
  85. builder: (context) => const IkFollowing(),
  86. ),
  87. );
  88. },
  89. ),
  90. spacer,
  91. ElevatedButton(
  92. child: const Text('Flame: Simple Example'),
  93. onPressed: () {
  94. Navigator.push(
  95. context,
  96. MaterialPageRoute<void>(
  97. builder: (context) => SpineFlameGameWidget(SimpleFlameExample()),
  98. ),
  99. );
  100. },
  101. ),
  102. spacer,
  103. ElevatedButton(
  104. child: const Text('Flame: Pre-load and share Spine data'),
  105. onPressed: () {
  106. Navigator.push(
  107. context,
  108. MaterialPageRoute<void>(
  109. builder: (context) => SpineFlameGameWidget(PreloadAndShareSpineDataExample()),
  110. ),
  111. );
  112. },
  113. ),
  114. spacer
  115. ])));
  116. }
  117. }
  118. void main() async {
  119. WidgetsFlutterBinding.ensureInitialized();
  120. await initSpineFlutter(enableMemoryDebugging: false);
  121. runApp(const MaterialApp(title: "Spine Examples", home: ExampleSelector()));
  122. }