所以可以说我建立了一个像这样的sliverList.
return new Container( child: new CustomScrollVIEw( scrollDirection: Axis.vertical, shrinkWrap: false, slivers: <Widget>[ new Sliverpadding( padding: const EdgeInsets.symmetric(vertical: 2.0), sliver: new SliverList( delegate: new SliverChildBuilderDelegate( (BuildContext context, int index) { ModelClass class= _List[index]; return new dismissible( key: new ObjectKey(_List[index]), child: ModelCard(class), ondismissed: (dismissDirection direction) { setState(() { _List.removeAt(index); direction == dismissDirection.endToStart; }); }, background: new Container( color: const color.fromrGBO(183, 28, 28, 0.8), child: new Center( child: new Text( "Item Removed", style: new TextStyle(color: colors.white), ), )), ); // return new ModelCard(class); }, childCount: _List.length), ), ), ], ));
现在我有一个名为ModelCard的无状态小部件,可以像这样填充列表
new Container( padding: EdgeInsets.fromLTRB(80.0, 10.0, 0.0, 0.0), child: new Text( "${class.ListDescription}", style: new TextStyle(), ), ),
现在我想有一个图标按钮来关闭一个项目,所以我将其添加到卡中
new Container( padding: EdgeInsets.fromLTRB(350.0, 20.0, 0.0, 0.0), child: new Iconbutton( icon: new Icon(Icons.delete), onpressed: () {}), ),
您如何在按下图标时在可d出的菜单按钮中实现可消除的窗口小部件呢?
解决方法:
好的,已经有一个可以满足您需求的软件包.
https://pub.dartlang.org/packages/flutter_slidable
A Flutter implementation of slIDable List item with directional slIDe
actions that can be dismissed.
用法:
new SlIDable( delegate: new SlIDableScrollDelegate(), actionExtentRatio: 0.25, child: new Container( color: colors.white, child: new ListTile( leading: new CircleAvatar( backgroundcolor: colors.indigoAccent, child: new Text(''), foregroundcolor: colors.white, ), Title: new Text('Tile n°'), subTitle: new Text('SlIDableDrawerDelegate'), ), ), actions: <Widget>[ new IconSlIDeAction( caption: 'Archive', color: colors.blue, icon: Icons.archive, onTap: () => _showSnackbar('Archive'), ), new IconSlIDeAction( caption: 'Share', color: colors.indigo, icon: Icons.share, onTap: () => _showSnackbar('Share'), ), ], );
总结 以上是内存溢出为你收集整理的android-是否有可能在Flutter中为SliverList中的按钮实现Dismissible小部件全部内容,希望文章能够帮你解决android-是否有可能在Flutter中为SliverList中的按钮实现Dismissible小部件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)