Giter Club home page Giter Club logo

flutter_swipe_action_cell's People

Contributors

ipcjs avatar kennir avatar luckysmg avatar robin-jw avatar simonkimi avatar sinoahpx avatar xutao123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_swipe_action_cell's Issues

作者你好,请问如何与你取得联系

�JingRui 同学你好,在网上看到了你的一些 iOS 和 Flutter 开发作品非常喜欢,我目前在微信就职,希望可以与你取得联系做进一步的交流。

Possible to use with horizontal scrollabe Widget?

great package so far, thank you !!!

I had some use cases where it perfectly suited my needs, but now I have one use case (and I think there will be some more) where I would like to have a horizontal scrollable widget (in my case it is just a ListView with scrollDirection: Axis.horizontal) and the swipe actions simultaneously.
When arriving to the end (or beginning) of my scrollable widget I would like to show your swipe actions.

Is this (or will this ever) be possible with your package?

Use AlertDialog in nestedAction

I have to implement a some custom widget like AlertDialog to show user that is she/he sure to cancel the order or not.
But the problem is the width and height of the dialog is bounded with SwipeAction -> widthSpace, width and height is bounded by parent height. So can't showDialog and will cause overflow.

刚开始时leadingActions为空的,再设置后滑不出来

你好,这个库的侧滑效果很不错,👍。
遇到了一个问题,如下:
刚开始时leadingActions为空的,然后有一个开关触发,设置了leadingActions,结果无法滑出来;
如果刚开始leadingActions不为空,接着设置为空,然后再设置leadingActions,就可以滑出来。
下面的代码,是在example项目基础上增加了一个isHaveLeading,通过这个参数,来控制leadingActions的显示。

bool isHaveLeading = false;

Widget _item(BuildContext ctx, int index) {

List<SwipeAction>? leadingActions;
if (isHaveLeading) {
  leadingActions = [
    SwipeAction(
        title: "delete",
        onTap: (handler) async {
          await handler(true);
          list.removeAt(index);
          setState(() {});
        }),
    SwipeAction(
        title: "action3", color: Colors.orange, onTap: (handler) {}),
  ];
}

return SwipeActionCell(
  controller: controller,
  index: index,

  // Required!
  key: ValueKey(list[index]),

  // Animation default value below
  // normalAnimationDuration: 400,
  // deleteAnimationDuration: 400,
  selectedForegroundColor: Colors.black.withAlpha(30),
  trailingActions: [
    SwipeAction(
        title: "delete",
        performsFirstActionWithFullSwipe: true,
        nestedAction: SwipeNestedAction(title: "confirm"),
        onTap: (handler) async {
          await handler(true);

          list.removeAt(index);
          setState(() {});
        }),
    SwipeAction(title: "action2", color: Colors.grey, onTap: (handler) {}),
  ],
  leadingActions: leadingActions,
  child: GestureDetector(
    onTap: () {
      Navigator.push(
          context, CupertinoPageRoute(builder: (ctx) => const HomePage()));
    },
    child: Padding(
      padding: const EdgeInsets.all(20.0),
      child: Text("This is index of ${list[index]}",
          style: const TextStyle(fontSize: 30)),
    ),
  ),
);

}

最新版本 2.2.2 导致打包失败

更换到 2.2.1 打包修复 Flutter 2.10.5版本

Running Gradle task 'assembleProfile'...                        
../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_swipe_action_cell-2.2.2/lib/core/cell.dart:1055:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
                            ^^^^^^^^^^^^^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_swipe_action_cell-2.2.2/lib/core/cell.dart:1063:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
                            ^^^^^^^^^^^^^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_swipe_action_cell-2.2.2/lib/core/swipe_pull_align_button.dart:59:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
                            ^^^^^^^^^^^^^^^^^^^^
../../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_swipe_action_cell-2.2.2/lib/core/swipe_pull_button.dart:68:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
                            ^^^^^^^^^^^^^^^^^^^^

Crash when dragging the swipe action cell item out of screen

════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building Container(bg: BoxDecoration(color: Color(0xff050505)), margin: EdgeInsets(1.0, 0.0, 1.0, 0.0)):
The getter 'position' was called on null.
Receiver: null
Tried calling: position

The relevant error-causing widget was
    Container 
When the exception was thrown, this was the stack
#0      Object.noSuchMethod  (dart:core-patch/object_patch.dart:51:5)
#1      _SwipeActionCellState._addScrollListener 
package:flutter_swipe_action_cell/core/swipe_action_cell.dart:207
#2      _SwipeActionCellState.didChangeDependencies 
package:flutter_swipe_action_cell/core/swipe_action_cell.dart:191
#3      StatefulElement._firstBuild 
package:flutter/…/widgets/framework.dart:4716
#4      ComponentElement.mount 
package:flutter/…/widgets/framework.dart:4531
...
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by widgets library ═══════════════════════════════════
'package:flutter/src/widgets/framework.dart': Failed assertion: line 5028 pos 14: '_dependents.isEmpty': is not true.
The relevant error-causing widget was
    MediaQuery 
lib/main.dart:98
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by scheduler library ═════════════════════════════════
Cannot get size from a render object that has not been through layout.
════════════════════════════════════════════════════════════════════════════════

[enhancement] Reorderable Cells

It would be very useful to have this functionality in EDIT mode, or at least a way to add a draggable button at right side.

image

这个颜色

518318DB-53F5-4B81-9A8B-5421E78BE0F8
这个颜色能改成上面透明的咩 下面的会给整个item套上一个颜色

Perform first action when full swipe not available

I am have implemented the first example of this package successfully and it works perfectly. Now, I want to implement the second example - Perform first action when full swipe, but it does not work as described.

Well, the performsFirstActionWithFullSwipe parameter is no longer available and I could not find anything that would help me to delete an item from the list when the user makes the full swipe.

cell expanding when used with tab bar

When I use swipe cell for tab bar with 3 screens, the action cell is expanding unexpectedly when I swipe(by tapping) to the third cell in particular. It is working as expected if I disable page transition animation on TabController. When sliding manually, everything is fine

如何设置滑动后的回弹效果

感谢插件作者,我想实现如视频里这样的回弹效果,是否可以自定义动画?

869_1687164670.mp4

看了一下代码, 我觉得首先需要修改普通的动画的曲线为 easeOutBack

    curvedAnim = CurvedAnimation(parent: controller, curve: Curves.easeOutBack);

其次,我认为需要再增加一个 animation 作为收回的动画(不需要 easeOutBack)

不知道这个思路是否正确?

谢谢

Bad state: No element

When the exception was thrown, this was the stack: 
#0      List.first (dart:core-patch/growable_array.dart:332:5)
#1      SwipeActionCellState._closeNestedAction (package:flutter_swipe_action_cell/core/cell.dart:661:33)
#2      SwipeActionCellState._scrollListener (package:flutter_swipe_action_cell/core/cell.dart:415:7)
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:308:24)
#4      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:412:5)
#5      ScrollPosition.beginActivity (package:flutter/src/widgets/scroll_position.dart:884:25)
#6      ScrollPositionWithSingleContext.beginActivity (package:flutter/src/widgets/scroll_position_with_single_context.dart:114:11)
#7      ScrollPositionWithSingleContext.drag (package:flutter/src/widgets/scroll_position_with_single_context.dart:264:5)
canEdit ? [
                    SwipeAction(
                        title: '编辑',
                        onTap: (CompletionHandler handler) async {
                          editAction?.call();
                        },
                        color: Colors.amber),
                  ] : []

滚动的时候报错

Empty actions list

Hey really nice package!
I have a little problem,
I want to show actions with a condition.
My application can be RTL and LTR, I need to set the leading actions if the direction of the app is ltr and trailing actions need to be empty. If the direction of the app is rtl I need to set the trailing actions and the leading actions need to be empty.
However, errors show up if the list of the actions is empty.
I looked at the code, and saw you initialize the actions with defaultActions list.
This is fine, but if I over swipe the item, there is a slight red background which is shown (an empty SwipeAction I suppose).
Here is a gif to show the issue:
VideoCrop1605800497478

I think you should allow null or an empty actions list.
Or fix the red background of the empty SwipeAction in the defaultActions list.
Thanks!

Error in xcode

show log below:
: Error: Member not found: 'Scrollable.maybeOf'.
scrollPosition = Scrollable.maybeOf(context)?.position;
^^^^^^^
code:
lib/core/cell.dart
Line 434: scrollPosition = Scrollable.maybeOf(context)?.position;

没有展开或者收回的回调

看了源码,只有一个开始滑动的回调 CellFingerOpenEvent,还有编辑模式的回调,找不到侧滑展开的回调和侧滑收回的回调,有什么好的办法监听到这两个事件吗

    // 监听侧滑 这个回调方法展开和收回都会执行,而且无法判断是展开还是收回
    SwipeActionStore.getInstance().bus.on<CellFingerOpenEvent>().listen((CellFingerOpenEvent event) {
      ValueKey<String> valueKey = event.key as ValueKey<String>;
      print('--->>> open: ${valueKey.value}  ${_swipeActionController.selectedSet.length}');
    });

version: flutter_swipe_action_cell: ^2.1.1
flutter version: 2.5.2 channel stable

Performance question

When i scroll ListView.builder than each new appears item triggers rebuild all of SvipeActionCell widgets.(9-15 pcs per time). is this behavior right and expected?
Screenshot 2022-05-04 at 17 09 12
When i remove SwipeActionCell widget, yhen builder builds only new IgnorePointer. What is my bad?
I tried to pass index as ValueKey, it doesn't help.

关于按钮内部内容居中问题

之前有很多同学反映按钮内部内容不居中,很难受,目前最新的版本2.0.3已经支持按钮内部的内容实现自动居中

BiG ISSSUEEEE!!!!

Hello, There is no controller available to open-cell at any index with swipeController however there is an option to close-all-cell, how can I close the cell without opening it !!!

add null-safety support

since flutter stable 2.0.0 is there with stable null safety, it would be nice to have this package migrated as well

Phone freeze and have to restart

Hey,
It's me again :)
I sometime encounter a weird behaviour with your package.
It is working as expected most of the times, but one time out of hundred when trying to open a cell it freezes my phone and I have to hard reset.

It is not happening anywhere in my app, except when trying to open a cell, that is why I think it is something to do with your package.

Is there anything that may cause a deadlock or a loop that never ends?
I don't have any logs to give because it is really random.

Please help,
Thank you!

How to create a useful issue(如何提一个有用的issue)

1. If you come across some bugs

you can try lastest version of this package.

2. If The bugs are found in lastest version,you should:

  • Provide demo code for me to reproduce bug quickly.The code can run directly
  • Provide a description for me .It can be text,or GIF or video to show me where the bug is.

If you have some enhancement advice

Just write in your issue directly.😀(Not write in this issue)

编辑模式删除最后一条有点问题

最后一条的数据已经没有了 但是还是会显示一条item 不仅是删除最后一条 把列表item全删了 只要导致列表item为0了 那些被删除的item的ui还在显示着 setState也没用

当trailingActions个数为一个的时候,删除按钮侧滑不能完全展示

截屏2021-05-17 下午4 42 01

截屏2021-05-17 下午4 42 21

Widget _item(BuildContext ctx, int index) {
return SwipeActionCell(
controller: controller,
index: index,
key: ValueKey(list[index]),

  ///animation default value below...
  normalAnimationDuration: 500,
  deleteAnimationDuration: 400,
  performsFirstActionWithFullSwipe: true,
  trailingActions: [
    SwipeAction(
        title: "取消删除",
        // nestedAction: SwipeNestedAction(title: "confirm"),
        onTap: (handler) async {
          await handler(true);

          list.removeAt(index);
          setState(() {});
        }),
    // SwipeAction(title: "action2", color: Colors.grey, onTap: (handler) {}),
  ],

action数组为一个的时候 取消删除 显示不完整

Delete animation problem

Hey!
Thank you for the package.
It seems there is a bug with the animations — when I touch the screen during the delete animation the cell loses its red color and some visual artifacts appear after it :-)
Please take a look.


Demo

Simulator.Screen.Recording.-.iPhone.11.Pro.Max.-.2023-03-08.at.15.33.04.mp4

Repro

import 'package:flutter/cupertino.dart';
import 'package:flutter_swipe_action_cell/flutter_swipe_action_cell.dart';

class X extends StatefulWidget {
  @override
  State<X> createState() => _XState();
}

class _XState extends State<X> {
  var items = List<String>.empty();

  @override
  void initState() {
    super.initState();
    items = List.generate(10, (index) => 'Item $index');
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      home: CupertinoPageScaffold(
        child: SafeArea(
          child: CustomScrollView(
            slivers: [
              SliverList(
                delegate: SliverChildBuilderDelegate(
                  childCount: items.length,
                  (_, index) {
                    return SwipeActionCell(
                      deleteAnimationDuration: 10000,
                      key: ValueKey(items[index]),
                      trailingActions: <SwipeAction>[
                        SwipeAction(
                          title: "delete",
                          onTap: (CompletionHandler handler) async {
                            await handler(true);
                            items.removeAt(index);
                            setState(() {});
                          },
                          color: CupertinoColors.destructiveRed,
                        ),
                      ],
                      child: Container(
                        height: 30,
                        child: Text(items[index]),
                        color: CupertinoColors.white,
                      ),
                    );
                  },
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

void main() {
  runApp(X());
}

I use the latest 3.1.0 version

Cannot get size from a render object that has been marked dirty for layout

问题描述:
在列表视图滑动到最后几行时,就会报出如下红字:
"Cannot get size from a render object that has been marked dirty for layout"
已经被该问题困扰了几天.

issue貌似来自:
package:flutter_swipe_action_cell/core/cell.dart:929:50

@OverRide
void didUpdateWidget(_ContentWidget oldWidget) {
super.didUpdateWidget(oldWidget);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (mounted) widget.onLayoutUpdate(context.size);
});
}

完整的报错信息:

════════ Exception caught by scheduler library ═══════════════════════════
The following assertion was thrown during a scheduler callback:
Cannot get size from a render object that has been marked dirty for layout.

The size of this render object is ambiguous because this render object has been modified since it was last laid out, which typically means that the size getter was called too early in the pipeline (e.g., during the build phase) before the framework has determined the size and position of the render objects during layout.

The size getter was called for the following element: _ContentWidget
state: __ContentWidgetState#a7aaf
The render object from which the size was to be obtained was: RenderTransform#45058 NEEDS-LAYOUT NEEDS-PAINT
... parentData: not positioned; offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=346.0, 0.0<=h<=Infinity)
... size: Size(346.0, 72.0)
... transform matrix: [0] 1.0,0.0,0.0,0.0
[1] 0.0,1.0,0.0,0.0
[2] 0.0,0.0,1.0,0.0
[3] 0.0,0.0,0.0,1.0
... origin: null
... alignment: null
... textDirection: ltr
... transformHitTests: false

Consider using debugPrintMarkNeedsLayoutStacks to determine why the render object in question is dirty, if you did not expect this.

When the exception was thrown, this was the stack:
#0 Element.size. (package:flutter/src/widgets/framework.dart:3875:9)
#1 Element.size (package:flutter/src/widgets/framework.dart:3893:6)
#2 __ContentWidgetState.didUpdateWidget. (package:flutter_swipe_action_cell/core/cell.dart:929:50)
#3 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#4 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1063:9)
...

pubspec.yaml使用的版本
flutter_swipe_action_cell: ^1.2.3

我的源码片段
是在ListView的itemBuilder中使用的:

Widget renderItemType([BuildContext context,List list,int idx]){
return SwipeActionCell(
key: ObjectKey(list[idx]),
child: ListItem(key:ValueKey(list[idx].code),leftTime:list[idx].lastTime,bigTitle:list[idx].name,subTitle:list[idx].code),
trailingActions: [
SwipeAction(
title: '删除',
style:TS.textWhite14,
color: Colors.red,
icon: Icon(Icons.delete,color: Colors.white,),
onTap: (CompletionHandler handler) async {
await handler(true);
list.removeAt(idx);
setState(() {});
},

    ),
  ],
);

}

我的开发环境:
flutter doctor -v
[√] Flutter (Channel unknown, 1.22.3, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
• Flutter version 1.22.3 at D:\android\flutter
• Framework revision 8874f21e79 (3 weeks ago), 2020-10-29 14:14:35 -0700
• Engine revision a1440ca392
• Dart version 2.10.3
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at D:\android\Sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = D:\android\Sdk
• Java binary at: D:\android\Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Android Studio (version 4.0)
• Android Studio at D:\android\Studio
• Flutter plugin installed
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

如何实现右上和右下圆角?

hello,先感谢老哥贡献组件。看到参数中有 backgroundRadius 参数,是实现左上和左下圆角的,貌似也是默认行为。

请问如何实现右上和右下圆角?

Height is not updated correctly

Hey,
I have encountered a bug.
When the child of the SwipeActionCell is changing its height, the swipe actions height is not updated to match the child.
Here is a video:

Swipe-bug.mp4
And here is the widget:
import 'package:flutter/material.dart';
import 'package:flutter_swipe_action_cell/flutter_swipe_action_cell.dart';

class Bug extends StatefulWidget {
  const Bug({super.key});

  @override
  State<Bug> createState() => _BugState();
}

class _BugState extends State<Bug> {
  bool isAdded = false;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        SwipeActionCell(
          key: const Key('bug'),
          leadingActions: [
            SwipeAction(
              onTap: (_) {},
              icon: const Icon(Icons.bug_report),
            ),
          ],
          child: Container(
            width: double.infinity,
            padding: const EdgeInsets.all(10),
            color: Colors.blue,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                const Text('bug'),
                if (isAdded) const Text('added'),
              ],
            ),
          ),
        ),
        ElevatedButton(
          onPressed: () {
            setState(() {
              isAdded = !isAdded;
            });
          },
          child: const Text('Toggle'),
        ),
      ],
    );
  }
}

Thanks in advanced :)

Two issues - Awaiting handler not working & SwipeNestedAction not closing when calling handler(false)

Hey,
I have found 2 issues.

  1. Awaiting the handler doesn't seem to work, I call handler(false) because I have my own animation when removing items from the list, but I want my animation to run after the slidable is closed. So I need to await the handler but its not waiting.
  2. SwipeNestedAction is not closing (stays in place) when calling handler(false) on tap. As I said, I have my own animations so when removing something from the list the nested action just stays there without closing. Need to point out that I have a custom content in all of the SwipeActions including the SwipeNestedAction (exactly like your example in the readme).

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.