0

I am trying to create a custom card in flutter that looks like this :

a busy cat

any advice or guidance will be greatly appreciated.

2 Answers 2

1

you should try out this https://flutter.dev/docs/development/ui/layout, it will help you greatly, in the other hand, for the upperright icon you could try Stack widget, the other components can fit in a column, something like:

Card(
  child: Stack(
    children: [
      Positioned(
        top: 0,
        right: 0,
        child: Container(
          decoration: BoxDecoration(
            gradient: RadialGradient(
              colors: [
                Colors.red,
                Colors.white
              ],

              // Todo: to achive it as you have it in the picture you need to play with the radialgradient, check the oficial documentation for radialgradient and check for center, stops and radius properties of radialgradient
            )
          ),
          child: Padding(padding: EdgeInsets.all(10.0), child: Icon(Icons.menu /*Replace it with your icon*/)),
        ),
      ),
      Padding(
        padding: EdgeInsets.all(20.0),
        child: Column(
          children: <Widget>[
            Text("some text"),
            Text("some text 2"),
            Align(
              alignment: Alignment.centerRight,
              child: Chip(
                label: Text('0'),
              ),
            ),
          ],
        ),
      )
    ],
  ),
);

it's not the whole answer, you need to play with sizes, height, width, paddings and margins, good luck

Sign up to request clarification or add additional context in comments.

Comments

0

You may use this widget everywhere.

CardService(
      icon: 'assets/icons/services/poll.svg',
      text: getTranslated(context, 'poll'),
      onTap: () {
        context.router.push(PollScreenRoute());
      },
    );

// card_service.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:theme_provider/theme_provider.dart';


class CardService extends StatelessWidget {

const CardService({this.text, this.onTap, this.icon});
final String? text;
final String? icon;
final GestureTapCallback? onTap;

@override
Widget build(BuildContext context) {
  var theme = ThemeProvider.controllerOf(context).theme.data;
    return Card(
     elevation: 4.0,
     shadowColor: Colors.black26,
     margin: EdgeInsets.all(0.0),
     shape: RoundedRectangleBorder(
       borderRadius: BorderRadius.circular(13.0),
     ),
    child: CupertinoButton(
     onPressed: onTap,
     color: theme.cardColor,
     alignment: Alignment.center,
     padding: EdgeInsets.symmetric(horizontal: 16.0),
     borderRadius: BorderRadius.circular(13.0),
     child: Column(
       mainAxisAlignment: MainAxisAlignment.center,
       crossAxisAlignment: CrossAxisAlignment.center,
       children: [
         CircleAvatar(
           radius: 23,
           backgroundColor: theme.primaryColor.withOpacity(0.1),
           child: SvgPicture.asset(icon!, height: 26.0, color: theme.primaryColor),
         ),
         SizedBox(height: 13.0),
         Text(
          text!,
          maxLines: 2,
          overflow: TextOverflow.ellipsis,
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 14.0,
            fontWeight: FontWeight.w500,
            fontFamily: 'Montserrat',
            color: theme.accentIconTheme.color,
          ),
        )
      ],
    ),
   ),
  );
 }
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.