Flutter Swipe Tabs with Cards

Flutter Swipe Tabs with Cards Tutorial

This is a flutter Swipe Tabs tutorial. How to switch through cards containing images by swiping forward or backwards or clicking the tabs.

We will have 6 Tabs in our application. The Tabs will be arranged beautifully in our appBar just below the title.

Each tab will have the tab title and icon. You can then click the tab or swipe it either from left to right or right to left.

Our TabViews will have Cards.Each Card will have an image and text.

Video Tutorial(ProgrammingWizards TV Channel)

Well we have a video tutorial as an alternative to this. If you prefer tutorials like this one then it would be good you subscribe to our YouTube channel.

Basically we have a TV for programming where do daily tutorials especially android.

Let’s look a flutter swipe tabs example with cards.

Flutter Swipe tabs with Cards Example

This is a simple flutter swipe tabs example.We use Dart programming language.

Flutter Swipe Tabs

Flutter Swipe Tabs

Here are the files we explore:

  1. pubspec.yaml
  2. lib/main.dart
(a). pubspec.yaml
name: mr_tabs
description: A new Flutter application.

    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #  - images/a_dot_burr.jpeg
  #  - images/a_dot_ham.jpeg
(b). main.dart

This is where we write our flutter code in dart programming language. In Dart it is very common to write several classes in a single file. So this simple file will have three classes.

Importing Packages in Flutter/Dart

But first we need to import some packages and we do that using the import keyword in dart.

import 'package:flutter/material.dart';

Here are the packages we are importing:

  1. material.dart : will give us material design widgets and theme.
Creating classes in Flutter/Dart

In Dart like in most C style programming languages you create a class using the class keyword. Classes are encapsulation mechanism in Object Oriented Programming languages.

In this case we create three classes:
1.class Category{..}

  1. class MrTabs extends StatelessWidget {..}
  2. class CategoryCard extends StatelessWidget {..}
import 'package:flutter/material.dart';

//Our Category Data Object
class Category {
  const Category({ this.name, this.icon });
  final String name;
  final IconData icon;

// List of Category Data objects.
const List<Category> categories = <Category>[
  Category(name: 'General', icon: Icons.assessment),
  Category(name: 'Tech', icon: Icons.code),
  Category(name: 'Lifestyle', icon: Icons.people),
  Category(name: 'Finance', icon: Icons.account_balance),
  Category(name: 'Education', icon: Icons.school),
  Category(name: 'Sports', icon: Icons.settings_input_composite),

// Our MrTabs class.
//Will build and return our app structure.
class MrTabs extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new DefaultTabController(
        length: categories.length,
        child: new Scaffold(
          appBar: new AppBar(
            title: const Text('Tabbed AppBar'),
            bottom: new TabBar(
              isScrollable: true,
              tabs: categories.map((Category choice) {
                return new Tab(
                  text: choice.name,
                  icon: new Icon(choice.icon),
          body: new TabBarView(
            children: categories.map((Category choice) {
              return new Padding(
                padding: const EdgeInsets.all(16.0),
                child: new CategoryCard(choice: choice),
       theme: new ThemeData(primaryColor: Colors.deepOrange),

// Our CategoryCard data object
class CategoryCard extends StatelessWidget {
  const CategoryCard({ Key key, this.choice }) : super(key: key);
  final Category choice;

  //build and return our card with icon and text
  Widget build(BuildContext context) {
    final TextStyle textStyle = Theme.of(context).textTheme.display1;
    return new Card(
      color: Colors.white,
      child: new Center(
        child: new Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            new Icon(choice.icon, size: 128.0, color: textStyle.color),
            new Text(choice.name, style: textStyle),
// Our main method
void main() {
  runApp(new MrTabs());


You can download full source code below.

No. Location Link
1. GitHub Direct Download
2. GitHub Browse

Best Regards,



Share an Example

Share an Example

What is the capital of Egypt? ( Cairo )