Pen Settings

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

Flutter

              
                /// Based on a layout screenshot someone asked how you'd implement
/// on the FlutterDev discord.

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: SafeArea(
        child: Scaffold(
          body: Center(
            child: Stats(),
          ),
        ),
      ),
    ),
  );
}

class Stats extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Card(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Row(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                StatColumn(
                  title: 'Total Subscribers',
                  amount: '71,987',
                  from: '70,946',
                  change: 12.0,
                ),
                SizedBox(
                  width: 1,
                  height: 80,
                  child: Container(color: Colors.grey.shade300),
                ),
                StatColumn(
                  title: 'Avg. Open Rate',
                  amount: '58.16%',
                  from: '58.14%',
                  change: 2.02,
                ),
                SizedBox(
                  width: 1,
                  height: 80,
                  child: Container(color: Colors.grey.shade300),
                ),
                StatColumn(
                  title: 'Avg. Click Rate',
                  amount: '24.57%',
                  from: '28.62%',
                  change: -4.05,
                ),
              ]),
        ],
      ),
    );
  }
}

class StatColumn extends StatelessWidget {
  final String title;
  final String amount;
  final String from;
  final double change;

  StatColumn({
    this.title,
    this.amount,
    this.from,
    this.change,
  });

  MaterialColor get _baseChipColor {
    if (change > 0) {
      return Colors.green;
    }
    if (change < 0) {
      return Colors.red;
    }
    return Colors.grey;
  }

  Color get _chipBackgroundColor => _baseChipColor.shade100;

  Widget get _chipIcon {
    IconData icon = Icons.trending_flat;
    if (change > 0) {
      icon = Icons.trending_up;
    }
    if (change < 0) {
      icon = Icons.trending_down;
    }
    return Icon(icon, size: 14, color: _chipTextColor);
  }

  Color get _chipTextColor => _baseChipColor.shade900;

  String get _formatChange => change.toString().replaceAll(RegExp(r'\.0$'), '');

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: LayoutBuilder(
        builder: (context, constraints) {
          var titleRow = Row(children: [
            Text(
              title,
              style: TextStyle(
                fontSize: 14,
              ),
            )
          ]);

          var amountText = Text(
            amount,
            style: TextStyle(
              color: Colors.deepPurple.shade800,
              fontWeight: FontWeight.bold,
              fontSize: 18,
            ),
          );

          var fromText = Text(
            'from $from',
            style: TextStyle(
              color: Colors.grey.shade500,
              fontWeight: FontWeight.bold,
              fontSize: 12,
            ),
          );

          var percentageChange = Container(
            padding: EdgeInsets.symmetric(vertical: 2, horizontal: 4),
            decoration: BoxDecoration(
              color: _chipBackgroundColor,
              borderRadius: BorderRadius.all(Radius.circular(20)),
            ),
            child: Row(children: <Widget>[
              _chipIcon,
              SizedBox(width: 4),
              Text(
                '$_formatChange%',
                style: TextStyle(
                    color: _chipTextColor,
                    fontWeight: FontWeight.bold,
                    fontSize: 13),
              ),
            ]),
          );

          if (constraints.maxWidth < 175) {
            return Padding(
              padding: EdgeInsets.symmetric(vertical: 16, horizontal: 8),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                titleRow,
                SizedBox(height: 4),
                Row(children: [amountText]),
                SizedBox(height: 4),
                Row(children: [fromText]),
                SizedBox(height: 4),
                Row(children: [percentageChange]),
              ]),
            );
          }

          if (constraints.maxWidth < 250) {
            return Padding(
              padding: EdgeInsets.symmetric(vertical: 16, horizontal: 8),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                titleRow,
                SizedBox(height: 4),
                Row(
                    crossAxisAlignment: CrossAxisAlignment.baseline,
                    textBaseline: TextBaseline.ideographic,
                    children: [
                      amountText,
                      SizedBox(width: 4),
                      fromText,
                    ]),
                SizedBox(height: 4),
                Row(children: [percentageChange]),
              ]),
            );
          }

          return Padding(
            padding: EdgeInsets.symmetric(vertical: 16, horizontal: 8),
            child: Column(mainAxisSize: MainAxisSize.min, children: [
              titleRow,
              SizedBox(height: 4),
              Row(
                  crossAxisAlignment: CrossAxisAlignment.baseline,
                  textBaseline: TextBaseline.ideographic,
                  children: [
                    amountText,
                    SizedBox(width: 4),
                    fromText,
                    Spacer(),
                    percentageChange,
                  ]),
            ]),
          );
        },
      ),
    );
  }
}

              
            
!
999px

Console