Skip to content

Commit

Permalink
Added colored print methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shinayser committed Jan 6, 2020
1 parent da88f2d commit b6ed169
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Add this to your pusbec.yaml dependencies:
```shinayser_essentials_flutter:
git:
url: https://github.com/shinayser/ShinayserEssentialsFlutter.git
ref: 1.18.0
ref: 1.19.0
```
1 change: 1 addition & 0 deletions lib/shinayser_essentials_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library shinayser_essentials_flutter;
export 'utils/utils.dart';
export 'utils/fade_page_route.dart';
export 'utils/util_extensions.dart';
export 'utils/color_print.dart';
export 'animation/showup.dart';
export 'animation/showdown.dart';
export 'animation/growup.dart';
Expand Down
48 changes: 48 additions & 0 deletions lib/utils/color_print.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'dart:core' as core;
import 'package:ansicolor/ansicolor.dart';

AnsiPen _green = AnsiPen()..green();
AnsiPen _red = AnsiPen()..red();
AnsiPen _white = AnsiPen()..white();
AnsiPen _blue = AnsiPen()..blue();
AnsiPen _yellow = AnsiPen()..yellow();
AnsiPen _black = AnsiPen()..black();
AnsiPen _cyan = AnsiPen()..cyan();
AnsiPen _magenta = AnsiPen()..magenta();

extension PrintExtension<T> on T {
void print() => core.print(this);

void printRed() => core.print(_red(this?.toString()));

void printYellow() => core.print(_yellow(this?.toString()));

void printBlack() => core.print(_black(this?.toString()));

void printGreen() => core.print(_green(this?.toString()));

void printWhite() => core.print(_white(this?.toString()));

void printBlue() => core.print(_blue(this?.toString()));

void printCyan() => core.print(_cyan(this?.toString()));

void printMagenta() => core.print(_magenta(this?.toString()));
}

void printRed(core.Object object) => core.print(_red(object?.toString()));

void printYellow(core.Object object) => core.print(_yellow(object?.toString()));

void printBlack(core.Object object) => core.print(_black(object?.toString()));

void printGreen(core.Object object) => core.print(_green(object?.toString()));

void printWhite(core.Object object) => core.print(_white(object?.toString()));

void printBlue(core.Object object) => core.print(_blue(object?.toString()));

void printCyan(core.Object object) => core.print(_cyan(object?.toString()));

void printMagenta(core.Object object) =>
core.print(_magenta(object?.toString()));
1 change: 0 additions & 1 deletion lib/widgets/advanced_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ abstract class AdvancedState<T extends StatefulWidget> extends State<T> {
MediaQueryData get media => context.mediaQuery;

NavigatorState get navigator => context.navigator;

}
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
ansicolor:
dependency: "direct main"
description:
name: ansicolor
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
archive:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: shinayser_essentials_flutter
description: A new Flutter project.
version: 1.18.0 #Don't forget to change on README.MD also
version: 1.19.0 #Don't forget to change on README.MD also
author:
homepage:

Expand All @@ -13,6 +13,7 @@ dependencies:

quiver: '>=2.0.0 <3.0.0'
rxdart: ^0.23.1
ansicolor: ^1.0.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit b6ed169

Please sign in to comment.