Closed kzrnm closed 1 year ago
If onSwipe is an async method, onEnd will be executed before onSwipe is completed.
onSwipe
onEnd
import 'package:appinio_swiper/appinio_swiper.dart'; import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); static const String _title = 'Swiper'; @override Widget build(BuildContext context) { return MaterialApp( title: _title, home: Scaffold( appBar: AppBar(title: const Text(_title)), body: Center( child: AppinioSwiper( onSwipe: (index, direction) async { await Future.delayed(const Duration(milliseconds: 200)); print({"name": "onSwipe", "index": index}); }, onEnd: () async { await Future.delayed(const Duration(milliseconds: 100)); print({"name": "onEnd"}); }, cardsCount: 3, cardsBuilder: (BuildContext context, int index) { return Container( alignment: Alignment.center, color: Colors.blue, child: Text(index.toString()), ); }, ), ), ), ); } }
{name: onSwipe, index: 1} {name: onSwipe, index: 2} {name: onEnd} {name: onSwipe, index: 3}
Hey @kzrnm yes you can.
If
onSwipe
is an async method,onEnd
will be executed beforeonSwipe
is completed.Code
Console