The Widget Card in Flutter.

Author
By Darío Rivera
Posted On in Flutter

One of the most used elements in mobile development are Cards. Flutter, of course, has a widget implementation for cards, which we can use in a very intuitive and dynamic way. Let's take a look at the Card widget.

To define a Card widget we can use the following structure.

Card(
  child: somWidget
);

Observe how a column of two Card elements would look like. If you still don't know how to use columns in Flutter, we recommend you to visit our article "Rows and Columns in Flutter".

icon widget

Below is the code for the previous example.

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Home()
  ));
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Card example')),
      body: Column(
        children: [
          Card(
            child: ListTile(
                leading: Icon(Icons.album),
                title: Text('18 and Life'),
                subtitle: Text('by Skid Row')
            ),
          ),
          Card(
            child: ListTile(
                leading: Icon(Icons.album),
                title: Text('Careless Whisper'),
                subtitle: Text('by George Michael')
            ),
          ),
        ],
      )
    );
  }
}

Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.