Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

tcard

a tinder like cards flutter plugin, can slide it’s children left or right. you can use it to show some images, videos and so on.

install

# pubspec.yaml
dependencies:
  tcard: ^1.3.3

uasge

normal widget

list<widget> cards = list.generate(
  5,
  (index) => container(
    color: colors.blue,
    child: center(
      child: text(
        '$index',
        style: textstyle(fontsize: 60, color: colors.white),
      ),
    ),
  ),
);

tcard(
  cards: cards,
)

cards --1-

network image

list<string> images = [
  'https://gank.io/images/5ba77f3415b44f6c843af5e149443f94',
  'https://gank.io/images/02eb8ca3297f4931ab64b7ebd7b5b89c',
  'https://gank.io/images/31f92f7845f34f05bc10779a468c3c13',
  'https://gank.io/images/b0f73f9527694f44b523ff059d8a8841',
  'https://gank.io/images/1af9d69bc60242d7aa2e53125a4586ad',
];

list<widget> cards = list.generate(
  images.length,
  (int index) {
    return container(
      decoration: boxdecoration(
        color: colors.white,
        borderradius: borderradius.circular(16.0),
        boxshadow: [
          boxshadow(
            offset: offset(0, 17),
            blurradius: 23.0,
            spreadradius: -13.0,
            color: colors.black54,
          )
        ],
      ),
      child: cliprrect(
        borderradius: borderradius.circular(16.0),
        child: image.network(
          images[index],
          fit: boxfit.cover,
        ),
      ),
    );
  },
);

tcard(
  size: size(400, 600),
  cards: cards,
);

images

use a controller to control

class myapp extends statefulwidget {
  @override
  _myappstate createstate() => _myappstate();
}

class _myappstate extends state<myapp> {
  tcardcontroller _controller = tcardcontroller();

  @override
  widget build(buildcontext context) {
    return materialapp(
      home: scaffold(
        body: column(
          mainaxisalignment: mainaxisalignment.center,
          children: [
            tcard(
              cards: cards,
              size: size(360, 480),
              controller: _controller,
              onforward: (index, info) {
                print(index);
              },
              onback: (index, info) {
                print(index);
              },
              onend: () {
                print('end');
              },
            ),
            sizedbox(
              height: 40,
            ),
            row(
              mainaxisalignment: mainaxisalignment.spacearound,
              children: <widget>[
                outlinebutton(
                  onpressed: () {
                    print(_controller);
                    _controller.back();
                  },
                  child: text('back'),
                ),
                outlinebutton(
                  onpressed: () {
                    _controller.reset();
                  },
                  child: text('reset'),
                ),
                outlinebutton(
                  onpressed: () {
                    _controller.forward();
                  },
                  child: text('forward'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

controller

determine the sliding direction

 tcard(
  cards: cards,
  size: size(360, 480),
  controller: _controller,
  onforward: (index, info) {
    print(index);
    print(info.direction);
    if (info.direction == swipdirection.right) {
      print('like');
    } else {
      print('dislike');
    }
  },
  onback: (index, info) {
    print(index);
  },
  onend: () {
    print('end');
  },
)

like

reset width new cards

list<widget> newcards = [];

tcardcontroller _controller = tcardcontroller();

_controller.reset(cards: newcards);

property

property type default description required
cards list<widget> null render cards true
size size null card size false
controller tcardcontroller null card controller false
onforward forwardcallback null forward animation callback false
onback backcallback null back animation callback false
onend endcallback null forward end callback false
lockyaxis bool false lock y axis gesture false
slidespeed double 20 how quick should it be slided? less is slower. 10 is a bit slow. 20 is a quick enough. false
delayslidefor int 500 how long does it have to wait until the next slide is sliable? less is quicker. 100 is fast enough. 500 is a bit slow. false

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Top