text_table 2.5.4

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 73

text_table

Renders style-able flex ascii tables.

Features

  • Customizable table borders
  • Column width customization
  • Flex column widths
  • Cell text alignment
  • Cell padding
  • Text truncation and ellipsis

TODO

  • [ ] Multiline cells

Usage

Simple example

main() {
  final Table tab = table(['Player', 'Team', 'Goals'])
    ..row(['Messi', 'Barcelona FC', 80])
    ..row(['Christiano Ronaldo', 'Real Madrid', 30])
    ..row(['Luiz Suarez', 'Barcelona FC', 50]);
  print(tab);
}
┌──────────────────┬────────────┬─────┐
│Player            │Team        │Goals│
┝━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━┿━━━━━┥
│Messi             │Barcelona FC│80   │
├──────────────────┼────────────┼─────┤
│Christiano Ronaldo│Real Madrid │30   │
├──────────────────┼────────────┼─────┤
│Luiz Suarez       │Barcelona FC│50   │
└──────────────────┴────────────┴─────┘

Text alignment

final Table tab = table(['Player', 'Team', 'Goals'],
    colWidths: [fixed(25), fixed(25), fixed(10)], globalAlign: Align.center)
  ..row(['Messi', 'Barcelona FC', 80])
  ..row(['Christiano Ronaldo', 'Real Madrid', 30])
  ..row(['Luiz Suarez', 'Barcelona FC', 50]);
┌─────────────────────────┬─────────────────────────┬──────────┐
│         Player          │          Team           │  Goals   │
┝━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━┥
│          Messi          │      Barcelona FC       │    80    │
├─────────────────────────┼─────────────────────────┼──────────┤
│   Christiano Ronaldo    │       Real Madrid       │    30    │
├─────────────────────────┼─────────────────────────┼──────────┤
│       Luiz Suarez       │      Barcelona FC       │    50    │
└─────────────────────────┴─────────────────────────┴──────────┘

Column specific text alignment

final Table tab = table(['Player', 'Team', 'Goals'],
    colWidths: [fixed(25), fixed(25), fixed(10)],
    aligns: [Align.left, Align.center, Align.right])
  ..row(['Messi', 'Barcelona FC', 80])
  ..row(['Christiano Ronaldo', 'Real Madrid', 30])
  ..row(['Luiz Suarez', 'Barcelona FC', 50]);
┌─────────────────────────┬─────────────────────────┬──────────┐
│Player                   │          Team           │     Goals│
┝━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━┥
│Messi                    │      Barcelona FC       │        80│
├─────────────────────────┼─────────────────────────┼──────────┤
│Christiano Ronaldo       │       Real Madrid       │        30│
├─────────────────────────┼─────────────────────────┼──────────┤
│Luiz Suarez              │      Barcelona FC       │        50│
└─────────────────────────┴─────────────────────────┴──────────┘

Padding

  final Table tab = table(['Player', 'Team', 'Goals'],
      globalPadding: pad(before: 2, after: 2))
    ..row(['Messi', 'Barcelona FC', 80])
    ..row(['Christiano Ronaldo', 'Real Madrid', 30])
    ..row(['Luiz Suarez', 'Barcelona FC', 50]);
┌──────────────────────┬────────────────┬─────────┐
│  Player              │  Team          │  Goals  │
┝━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━┿━━━━━━━━━┥
│  Messi               │  Barcelona FC  │  80     │
├──────────────────────┼────────────────┼─────────┤
│  Christiano Ronaldo  │  Real Madrid   │  30     │
├──────────────────────┼────────────────┼─────────┤
│  Luiz Suarez         │  Barcelona FC  │  50     │
└──────────────────────┴────────────────┴─────────┘

Elipses

  final Table tab = table(['Player', 'Team', 'Goals'])
    ..row(['Messi', 'Barcelona FC', 80])
    ..row(['Christiano Ronaldo', 'Real Madrid', 30])
    ..row(['Luiz Suarez', 'Barcelona FC', 50]);
  tab.maxColWidths[0] = fixed(10);
  tab.minColWidths[2] = fixed(10);
┌──────────┬────────────┬──────────┐
│Player    │Team        │Goals     │
┝━━━━━━━━━━┿━━━━━━━━━━━━┿━━━━━━━━━━┥
│Messi     │Barcelona FC│80        │
├──────────┼────────────┼──────────┤
│Christi...│Real Madrid │30        │
├──────────┼────────────┼──────────┤
│Luiz Su...│Barcelona FC│50        │
└──────────┴────────────┴──────────┘

No borders

  final Table tab = table(['Player', 'Team', 'Goals'],
      globalPadding: pad(after: 5), border: Border.compact)
    ..row(['Messi', 'Barcelona FC', 80])
    ..row(['Christiano Ronaldo', 'Real Madrid', 30])
    ..row(['Luiz Suarez', 'Barcelona FC', 50]);
Player                 Team             Goals     
--------------------------------------------------
Messi                  Barcelona FC     80        
Christiano Ronaldo     Real Madrid      30        
Luiz Suarez            Barcelona FC     50        

Border styles

    final Table tab = table(
      ['Player', 'Team', 'Goals'],
      border: Border.doubleLines,
    )
      ..row(['Messi', 'Barcelona FC', 80])
      ..row(['Christiano Ronaldo', 'Real Madrid', 30])
      ..row(['Luiz Suarez', 'Barcelona FC', 50]);
╔══════════════════╤════════════╤═════╗
║Player            │Team        │Goals║
╠══════════════════╪════════════╪═════╣
║Messi             │Barcelona FC│80   ║
╟──────────────────┼────────────┼─────╢
║Christiano Ronaldo│Real Madrid │30   ║
╟──────────────────┼────────────┼─────╢
║Luiz Suarez       │Barcelona FC│50   ║
╚══════════════════╧════════════╧═════╝

Out-of-the-box styles

TODO

Flex columns

  final Table tab = table(['Player', 'Team', 'Goals'],
      width: 90,
      colWidths: [flex(2), flex(1), fixed(5)],
      maxColWidths: [fixed(22)],
      globalPadding: padEven(1))
    ..row(['Messi', 'Barcelona FC', 80])
    ..row(['Christiano Ronaldo', 'Real Madrid', 30])
    ..row(['Luiz Suarez', 'Barcelona FC', 50]);
┌────────────────────────┬───────────────────────────────────────────────────────┬───────┐
│ Player                 │ Team                                                  │ Goals │
┝━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━┥
│ Messi                  │ Barcelona FC                                          │ 80    │
├────────────────────────┼───────────────────────────────────────────────────────┼───────┤
│ Christiano Ronaldo     │ Real Madrid                                           │ 30    │
├────────────────────────┼───────────────────────────────────────────────────────┼───────┤
│ Luiz Suarez            │ Barcelona FC                                          │ 50    │
└────────────────────────┴───────────────────────────────────────────────────────┴───────┘

Changelog

2.5.4

  • Bug fix when there is only row

2.5.3

  • Headless table

2.5.2

  • Fixes for Dart2

2.5.1

  • Padding
  • Flex tables
  • Column width customization
  • Column width estimation

1.0.0

  • Single line tables

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  text_table: "^2.5.4"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:text_table/text_table.dart';
        
Version Uploaded Documentation Archive
2.5.4 Apr 9, 2018 Go to the documentation of text_table 2.5.4 Download text_table 2.5.4 archive
2.5.3 Mar 24, 2018 Go to the documentation of text_table 2.5.3 Download text_table 2.5.3 archive
2.5.2 Mar 19, 2018 Go to the documentation of text_table 2.5.2 Download text_table 2.5.2 archive
2.5.1 Jan 2, 2018 Go to the documentation of text_table 2.5.1 Download text_table 2.5.1 archive
1.0.0 Jan 2, 2018 Go to the documentation of text_table 1.0.0 Download text_table 1.0.0 archive

Analysis

We analyzed this package on Apr 9, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.46.0
  • pana: 0.10.6

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
47 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
73
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:text_table/text_table.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use text_table.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
Dev dependencies
test ^0.12.0