Advertisement
Guest User

Untitled

a guest
Aug 8th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.60 KB | None | 0 0
  1. Draggable buildRecursiveStack(List<PCard> cards, int depth) {
  2.   if (cards.length == 0) {
  3.     return null;
  4.   }
  5.   PCard card = cards.first;
  6.   List<PCard> ncards = new List<PCard>.from(cards);
  7.   ncards.removeAt(0);
  8.  
  9.   return Draggable(
  10.       childWhenDragging: Container(),
  11.       feedback: Container(
  12.         height: 300,
  13.         width: 50,
  14.         child: Stack(
  15.           children: cards.map((card) {
  16.             return Positioned(
  17.                 top: 20.0 * depth + 20.0 * cards.indexOf(card),
  18.                 child: Container(
  19.                     decoration: BoxDecoration(
  20.                       borderRadius: BorderRadius.circular(4.0),
  21.                       color: Colors.white,
  22.                       border: Border.all(color: Colors.black),
  23.                     ),
  24.                     child: Image.asset(
  25.                       card.AsettName,
  26.                       scale: 6,
  27.                     )));
  28.           }).toList(),
  29.         ),
  30.       ),
  31.       child: Stack(children: () {
  32.         List<Widget> a = [
  33.           Positioned(
  34.               top: 20.0 * depth,
  35.               child: Container(
  36.                   decoration: BoxDecoration(
  37.                     borderRadius: BorderRadius.circular(4.0),
  38.                     color: Colors.white,
  39.                     border: Border.all(color: Colors.black),
  40.                   ),
  41.                   child: Image.asset(
  42.                     card.AsettName,
  43.                     scale: 6,
  44.                   ))),
  45.           buildRecursiveStack(ncards, depth + 1)
  46.         ];
  47.         a.removeWhere((value) => value == null);
  48.         return a;
  49.       }()));
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement