Advertisement
IOxxy

AnimatedList remove

Sep 14th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.40 KB | None | 0 0
  1. AnimatedList(
  2.   key: animatedListKey,
  3.   shrinkWrap: true,
  4.   physics: NeverScrollableScrollPhysics(),
  5.   initialItemCount: menu.details.length,
  6.   itemBuilder: (context, index, animation){
  7.     return SizeTransition(
  8.       sizeFactor: animation.drive(Tween(begin: 0.3, end: 1)),
  9.       axis: Axis.vertical,
  10.       child: FadeTransition(
  11.         opacity: animation.drive(Tween(begin: 0, end: 1)),
  12.         child: Padding(
  13.           padding: const EdgeInsets.symmetric(vertical: 10.0),
  14.           child: Row(
  15.             children: <Widget>[
  16.               Flexible(
  17.                 fit: FlexFit.loose,
  18.                 child: TextFormField(
  19.                   initialValue: menu.details[index],
  20.                   onChanged: (value){
  21.                     menu.details[index] = value;
  22.                   },
  23.                   decoration: InputDecoration(
  24.                       fillColor: Colors.grey[300],
  25.                       filled: true,
  26.                       contentPadding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
  27.                       border: OutlineInputBorder(borderRadius: BorderRadius.circular(100)),
  28.                       disabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.amber)),
  29.                       hintText: "Pietanza",
  30.                   ),
  31.                 ),
  32.               ),
  33.  
  34.               IconButton(
  35.                 icon: Icon(Icons.clear),
  36.                 onPressed: () {
  37.  
  38.                   print("\n\ndel" + index.toString() + "\n\n");
  39.  
  40.  
  41.  
  42.  
  43.                   AnimatedList.of(context).removeItem(index, (context, animation){
  44.  
  45.                     return SizeTransition(
  46.                       sizeFactor: animation.drive(Tween(begin: 0, end: 1)),
  47.                       axis: Axis.vertical,
  48.                       child: FadeTransition(
  49.                         opacity: animation.drive(Tween(begin: 0, end: 1)),
  50.                         child: Padding(
  51.                           padding: const EdgeInsets.symmetric(vertical: 10.0),
  52.                           child: Row(
  53.                             children: <Widget>[
  54.                               Flexible(
  55.                                 fit: FlexFit.loose,
  56.                                 child: TextFormField(
  57.  
  58.                                   decoration: InputDecoration(
  59.                                     fillColor: Colors.grey[300],
  60.                                     filled: true,
  61.                                     contentPadding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
  62.                                     border: OutlineInputBorder(borderRadius: BorderRadius.circular(100)),
  63.                                     disabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.amber)),
  64.                                     hintText: "Pietanza",
  65.                                   ),
  66.                                 ),
  67.                               ),
  68.  
  69.                               IconButton(
  70.                                 icon: Icon(Icons.clear),
  71.                                 onPressed: (){
  72.  
  73.                                 },
  74.                               )
  75.  
  76.                             ],
  77.                           ),
  78.                         ),
  79.                       ),
  80.                     );
  81.                   });
  82.  
  83.                   menu.details.removeAt(index);
  84.  
  85.                 },
  86.               )
  87.  
  88.             ],
  89.           ),
  90.         ),
  91.       ),
  92.     );
  93.   },
  94. ),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement