main.dart 3.2 KB

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