02 Flutter Card App

This simple Contact Card is made with flutter by following a tutorial from Angela you in Udemy

App Screenshot



main.dart
import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';
void main() {
  runApp(MyApp());}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,      theme: ThemeData(
        primaryColor: Colors.blue,      ),      home: MyHomeScreen(),    );  }
}

class MyHomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.teal,      body: SafeArea(
        child: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topLeft,              end: Alignment.bottomRight,              colors: [Colors.blue[400], Colors.blue[900]],            ),          ),          alignment: Alignment.bottomCenter,          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,                children: <Widget>[
                  Container(
                    padding: EdgeInsets.all(3),                    decoration: BoxDecoration(
                      color: Colors.white,                      shape: BoxShape.circle,                      boxShadow: [
                        new BoxShadow(
                          color: Colors.black.withOpacity(0.6),                          blurRadius: 10.0,                          offset: Offset(2, 4),                        ),                      ],                    ),                    child: CircleAvatar(
                      radius: 50,                      backgroundColor: Colors.grey[400],                      backgroundImage: AssetImage('images/me_arif_glass.jpg'),                      child: SizedBox(
                        width: 50,                        height: 50,                      ),                    ),                  ),                  Text(
                    'Naimur H.',                    style: TextStyle(
                      fontSize: 35,                      color: Colors.white,                      fontFamily: 'Pacifico',                    ),                  ),                  Text(
                    'Flutter Learner'.toUpperCase(),                    style: TextStyle(
                      fontSize: 15,                      color: Colors.white,                      fontFamily: 'SourceSansPro',                      letterSpacing: 2.0,                    ),                  ),                  SizedBox(
                    width: 150,                    height: 20,                    child: Divider(
                      color: Colors.white,                      thickness: 1,                    ),                  ),                  contactInfo(Icons.phone, '+880 1737 959 836',                      Theme.of(context).primaryColor),                  contactInfo(Icons.mail, 'imuhasan98@gmail.com',                      Theme.of(context).primaryColor),                ],
          )
        ),      ),    );  }

  contactInfo(IconData iconName, String s, Color color) {
    return Card(
      margin: EdgeInsets.symmetric(horizontal: 10, vertical: 5),      child: InkWell(
        splashColor: Colors.grey[400],        onTap: () {
          if (s == '+880 1737 *** 836')
            _launchPhone();          else if (s == 'imuhasa**@gmail.com') _launchMail();        },        child: ListTile(
          leading: Icon(
            iconName,            color: color,          ),          title: Text(
            s,            style: TextStyle(color: color),          ),        ),      ),    );  }

  _launchPhone() async {
    const url = 'tel://+8801737959***';    if (await canLaunch(url)) {
      await launch(url);    } else {
      throw 'Could not launch $url';    }
  }

  _launchMail() async {
    const url = 'mailto:imuhasan98@gmail.com';    if (await canLaunch(url)) {
      await launch(url);    } else {
      throw 'Could not launch $url';    }
  }
}

pubspec.yaml

name: Naimur

version: 1.0.0+1

environment:
  sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
  url_launcher: ^5.2.7
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
dev_dependencies:
  flutter_test:
    sdk: flutter


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/me_arif_glass.jpg

  fonts:
    - family: Pacifico
      fonts:
        - asset: fonts/Pacifico-Regular.ttf
    - family: SourceSansPro
      fonts:
        - asset: fonts/SourceSansPro-Regular.ttf


Find me on:
https://twitter.com/naimurhasanrwd

Comments