New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when dragging the swipe action cell item out of screen #1
Comments
Can you give me your demo code? I just cant reproduce your problem.. @gliese667c |
I guess that you put cell in a widget that is not scrollable .You should put cells in ListView or CustomScrollView....instead of Column...@gliese667c |
No, I put it in ReorderableListView, the long-press cell will crash the app. import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swipe_action_cell/core/swipe_action_cell.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Page1(
title: "haha",
),
);
}
}
class Page1 extends StatefulWidget {
Page1({Key key, this.title}) : super(key: key);
final String title;
@override
_Page1State createState() => _Page1State();
}
class _Page1State extends State<Page1> {
List list;
@override
void initState() {
super.initState();
list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ReorderableListView(
onReorder: (_, __) {},
children: _buildList(),
),
);
}
List<Widget> _buildList() {
return List.generate(list.length, (index) => _item(index));
}
Widget _item(int index) {
return SwipeActionCell(
///this key is necessary
key: ObjectKey(list[index]),
///this is the same as iOS native
performsFirstActionWithFullSwipe: true,
actions: <SwipeAction>[
SwipeAction(
title: "delete",
onTap: (CompletionHandler handler) async {
await handler(true);
list.removeAt(index);
setState(() {});
},
color: Colors.red),
SwipeAction(
widthSpace: 120,
title: "popAlert",
onTap: (CompletionHandler handler) async {
///false means that you just do nothing,it will close
/// action buttons by default
handler(false);
showCupertinoDialog(
context: context,
builder: (c) {
return CupertinoAlertDialog(
title: Text('ok'),
actions: <Widget>[
CupertinoDialogAction(
child: Text('confirm'),
isDestructiveAction: true,
onPressed: () {
Navigator.pop(context);
},
),
],
);
});
},
color: Colors.orange),
],
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("this is index of ${list[index]}", style: TextStyle(fontSize: 40)),
),
);
}
}
|
Thanks for your response. I will try your code to find problem. |
I have pushed a new version of this package (1.0.3+1). You can try again.@gliese667c |
I will close this issue . If there are problems remains , you can reopen this issue whenever you want |
The text was updated successfully, but these errors were encountered: