diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json new file mode 100644 index 0000000..f8248b6 --- /dev/null +++ b/.dart_tool/package_config.json @@ -0,0 +1,140 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "async", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.6.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "boolean_selector", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "characters", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "charcode", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "clock", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "collection", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "fake_async", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "flutter", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "flutter_test", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter_test", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "matcher", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "meta", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "path", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "sky_engine", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/bin/cache/pkg/sky_engine", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "source_span", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "stack_trace", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "stream_channel", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "string_scanner", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "term_glyph", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "test_api", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "typed_data", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "vector_math", + "rootUri": "file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, + { + "name": "colorize_text_avatar", + "rootUri": "../", + "packageUri": "lib/", + "languageVersion": "2.12" + } + ], + "generated": "2021-06-02T22:17:32.541394Z", + "generator": "pub", + "generatorVersion": "2.13.0" +} diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset new file mode 100644 index 0000000..297da08 --- /dev/null +++ b/.dart_tool/package_config_subset @@ -0,0 +1,89 @@ +colorize_text_avatar +2.12 +file:///home/rosalinda/Downloads/colorize-text-avatar/ +file:///home/rosalinda/Downloads/colorize-text-avatar/lib/ +async +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.6.1/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.6.1/lib/ +boolean_selector +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ +characters +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ +charcode +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ +clock +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ +collection +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ +fake_async +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ +matcher +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ +meta +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ +path +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/ +source_span +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/ +stack_trace +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ +stream_channel +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ +string_scanner +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ +term_glyph +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ +test_api +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0/lib/ +typed_data +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ +vector_math +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/ +file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ +sky_engine +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/bin/cache/pkg/sky_engine/ +file:///home/rosalinda/snap/flutter/common/flutter/bin/cache/pkg/sky_engine/lib/ +flutter +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter/ +file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter/lib/ +flutter_test +2.12 +file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter_test/ +file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter_test/lib/ +2 diff --git a/.dart_tool/version b/.dart_tool/version new file mode 100644 index 0000000..e3a4f19 --- /dev/null +++ b/.dart_tool/version @@ -0,0 +1 @@ +2.2.0 \ No newline at end of file diff --git a/.packages b/.packages new file mode 100644 index 0000000..3597028 --- /dev/null +++ b/.packages @@ -0,0 +1,28 @@ +# This file is deprecated. Tools should instead consume +# `.dart_tools/package_config.json`. +# +# For more info see: https://dart.dev/go/dot-packages-deprecation +# +# Generated by pub on 2021-06-02 15:17:32.485655. +async:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.6.1/lib/ +boolean_selector:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ +characters:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ +charcode:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ +clock:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ +collection:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ +fake_async:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ +flutter:file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter/lib/ +flutter_test:file:///home/rosalinda/snap/flutter/common/flutter/packages/flutter_test/lib/ +matcher:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ +meta:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ +path:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/ +sky_engine:file:///home/rosalinda/snap/flutter/common/flutter/bin/cache/pkg/sky_engine/lib/ +source_span:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/ +stack_trace:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ +stream_channel:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ +string_scanner:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ +term_glyph:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ +test_api:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.3.0/lib/ +typed_data:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ +vector_math:file:///home/rosalinda/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ +colorize_text_avatar:lib/ diff --git a/example/lib/main.dart b/example/lib/main.dart index 21bbeb2..ff72965 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,49 +1,22 @@ import 'package:flutter/material.dart'; - import 'package:colorize_text_avatar/colorize_text_avatar.dart'; -void main() { - runApp(MyApp()); -} +void main() => runApp(MyApp()); class MyApp extends StatelessWidget { - // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Auto Colorized Avatar', debugShowCheckedModeBanner: false, - theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, - brightness: Brightness.dark, - ), - home: MyHomePage(title: 'Flutter Auto Colorized Avatar'), + theme: ThemeData(primarySwatch: Colors.blue, brightness: Brightness.dark), + home: const MyHomePage(), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key? key, required this.title}) : super(key: key); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; + const MyHomePage({Key? key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); @@ -52,224 +25,129 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. return Scaffold( - appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), + appBar: AppBar(title: Text('Flutter Auto Colorized Avatar')), body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Example Colorized Avatars', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), + child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ + Text( + 'Example Colorized Avatars', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), + ), + const SizedBox(height: 20), + Row(mainAxisAlignment: MainAxisAlignment.center, children: const [ + TextAvatar( + shape: BoxShape.circle, + text: "Ali Akalın", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + shape: BoxShape.circle, + text: "Bulut Peker", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + shape: BoxShape.circle, + text: "Ceylin Oztürk", + numberLetters: 2, + ), + SizedBox(width: 12), + Text('.....'), + SizedBox(width: 12), + TextAvatar( + shape: BoxShape.circle, + text: "Xantos Salvo", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + shape: BoxShape.circle, + text: "Yuval Noah", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + shape: BoxShape.circle, + text: "Zoey Gen", + numberLetters: 2, + ), + ]), + const SizedBox(height: 20), + Row(crossAxisAlignment: CrossAxisAlignment.center, children: const [ + TextAvatar( + text: "Ali Akalın", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + text: "Bulut Peker", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + text: "Ceylin Oztürk", + numberLetters: 2, + ), + SizedBox(width: 12), + Text('.....'), + SizedBox(width: 12), + TextAvatar( + text: "Xantos Salvo", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + text: "Yuval Noah", + numberLetters: 2, + ), + SizedBox(width: 12), + TextAvatar( + text: "Zoey Gen", + numberLetters: 2, ), - SizedBox( - height: 20, + ]), + const SizedBox(height: 20), + Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + TextAvatar( + text: "Ali Akalın", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Ali Akalın", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Bulut Peker", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Ceylin Oztürk", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - Text('.....'), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Xantos Salvo", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Yuval Noah", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - shape: Shape.Circular, - text: "Zoey Gen", - numberLetters: 2, - ), - ], + SizedBox(width: 12), + TextAvatar( + text: "Bulut Peker", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - SizedBox( - height: 20, + SizedBox(width: 12), + TextAvatar( + text: "Ceylin Oztürk", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextAvatar( - textColor: Colors.white, - text: "Ali Akalın", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Bulut Peker", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Ceylin Oztürk", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - Text('.....'), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Xantos Salvo", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Yuval Noah", - numberLetters: 2, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Zoey Gen", - numberLetters: 2, - ), - ], + SizedBox(width: 12), + Text('.....'), + SizedBox(width: 12), + TextAvatar( + text: "Xantos Salvo", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - SizedBox( - height: 20, + SizedBox(width: 12), + TextAvatar( + text: "Yuval Noah", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - TextAvatar( - textColor: Colors.white, - text: "Ali Akalın", - numberLetters: 1, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Bulut Peker", - numberLetters: 1, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Ceylin Oztürk", - numberLetters: 1, - ), - SizedBox( - width: 12, - ), - Text('.....'), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Xantos Salvo", - numberLetters: 1, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Yuval Noah", - numberLetters: 1, - ), - SizedBox( - width: 12, - ), - TextAvatar( - textColor: Colors.white, - text: "Zoey Gen", - numberLetters: 1, - ), - ], + SizedBox(width: 12), + TextAvatar( + text: "Zoey Gen", + numberLetters: 1, + borderRadius: BorderRadius.circular(8), ), - ], - ), + ]), + ]), ), ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 24c967c..8c7015a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -46,10 +46,10 @@ packages: colorize_text_avatar: dependency: "direct main" description: - name: colorize_text_avatar - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" + path: ".." + relative: true + source: path + version: "1.0.2" cupertino_icons: dependency: "direct main" description: @@ -106,7 +106,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -141,7 +141,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b237007..24be615 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,20 +1,7 @@ name: example description: A new Flutter project. -# The following line prevents the package from being accidentally published to -# pub.dev using `pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev - -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +publish_to: 'none' version: 1.0.0+1 environment: @@ -23,55 +10,45 @@ environment: dependencies: flutter: sdk: flutter - colorize_text_avatar: ^1.0.1 - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. + colorize_text_avatar: + path: ../ cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: sdk: flutter -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to 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/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/colorize_text_avatar.dart b/lib/colorize_text_avatar.dart index b7ba539..3c23946 100644 --- a/lib/colorize_text_avatar.dart +++ b/lib/colorize_text_avatar.dart @@ -1,5 +1,3 @@ library colorize_text_avatar; -export 'src/constants/colors.dart'; -export 'src/constants/enums.dart'; export 'src/colorized_text_avatar.dart'; diff --git a/lib/src/colorized_text_avatar.dart b/lib/src/colorized_text_avatar.dart index 75102c0..437a048 100644 --- a/lib/src/colorized_text_avatar.dart +++ b/lib/src/colorized_text_avatar.dart @@ -1,127 +1,65 @@ -import 'package:colorize_text_avatar/colorize_text_avatar.dart'; import 'package:colorize_text_avatar/src/constants/colors.dart'; -import 'package:colorize_text_avatar/src/constants/enums.dart'; import 'package:flutter/material.dart'; class TextAvatar extends StatelessWidget { - Shape? shape; - Color? backgroundColor; - Color? textColor; - double? size; - final String? text; - final double? fontSize; - final int? numberLetters; - final FontWeight? fontWeight; - final String? fontFamily; - final bool? upperCase; + const TextAvatar({ + Key? key, + required this.text, + this.numberLetters = 2, + this.upperCase = false, + TextStyle? style, + this.width = 48, + this.height = 48, + this.borderRadius, + this.shape = BoxShape.rectangle, + this.backgroundColor, + }) : style = style ?? const TextStyle(color: Colors.white), + super(key: key); - TextAvatar( - {Key? key, - @required this.text, - this.textColor, - this.backgroundColor, - this.shape, - this.numberLetters, - this.size, - this.fontWeight = FontWeight.bold, - this.fontFamily, - this.fontSize = 16, - this.upperCase = false}) { - //assert(numberLetters! > 0); - } + final String text; + final int numberLetters; + final bool upperCase; + final TextStyle style; + + final BoxShape shape; + final double? width, height; + final Color? backgroundColor; + final BorderRadiusGeometry? borderRadius; @override Widget build(BuildContext context) { - shape = (shape == null) ? Shape.Rectangle : shape; - size = (size == null || size! < 32.0) ? 48.0 : size; - backgroundColor = _colorBackgroundConfig(); - textColor = _colorTextConfig(); - return _textDisplay(); - } - - Color _colorBackgroundConfig() { - if (RegExp(r'[A-Z]|').hasMatch( - _textConfiguration(), - )) { - backgroundColor = - colorData[_textConfiguration()[0].toLowerCase().toString()]; - } - return backgroundColor!; - } + final String textConfiguration = _textConfiguration(); - Color _colorTextConfig() { - if (textColor == null) - return Colors.white; - else - return textColor!; - } - - String _toString({String? value}) { - return String.fromCharCodes( - value!.runes.toList(), + return Container( + width: width, + height: height, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: borderRadius, + color: _colorBackgroundConfig(textConfiguration), + shape: shape, + ), + child: Text(textConfiguration, style: style), ); } - String _textConfiguration() { - var newText = text == null ? '?' : _toString(value: text); - newText = upperCase! ? newText.toUpperCase() : newText; - var arrayLeeters = newText.trim().split(' '); - - if (arrayLeeters.length > 1 && arrayLeeters.length == numberLetters) { - return '${arrayLeeters[0][0].trim()}${arrayLeeters[1][0].trim()}'; + Color? _colorBackgroundConfig(String text) { + Color? background = backgroundColor; + if (RegExp(r'[A-Z]|').hasMatch(text)) { + background = colorData[text[0].toLowerCase().toString()]; } - - return '${newText[0]}'; + return background; } - Widget _buildText() { - return Text( - _textConfiguration(), - style: TextStyle( - color: textColor, - fontSize: fontSize, - fontWeight: fontWeight, - fontFamily: fontFamily, - ), - ); - } + String _textConfiguration() { + String newText = String.fromCharCodes(text.runes.toList()); + newText = upperCase ? newText.toUpperCase() : newText; + List arrayLetters = newText.trim().split(' '); - _buildTextType() { - switch (shape) { - case Shape.Rectangle: - return RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), - ); - case Shape.Circular: - return RoundedRectangleBorder( - borderRadius: BorderRadius.circular(size! / 2), - ); - case Shape.None: - return RoundedRectangleBorder( - borderRadius: BorderRadius.circular(0.0), - ); - default: - { - return RoundedRectangleBorder( - borderRadius: BorderRadius.circular(size! / 2), - ); - } + if (arrayLetters.length > 1 && arrayLetters.length == numberLetters) { + return '${arrayLetters[0][0].trim()}${arrayLetters[1][0].trim()}'; } - } - Widget _textDisplay() { - return Container( - child: Material( - shape: _buildTextType(), - color: backgroundColor, - child: Container( - height: size, - width: size, - child: Center( - child: _buildText(), - ), - ), - ), - ); + return '${newText[0]}'; } } diff --git a/lib/src/constants/colors.dart b/lib/src/constants/colors.dart index f420f57..9a1128c 100644 --- a/lib/src/constants/colors.dart +++ b/lib/src/constants/colors.dart @@ -1,6 +1,6 @@ import 'dart:ui'; -var colorData = { +const Map colorData = { "a": Color.fromRGBO(226, 95, 81, 1), "b": Color.fromRGBO(242, 96, 145, 1), "c": Color.fromRGBO(187, 101, 202, 1), diff --git a/lib/src/constants/enums.dart b/lib/src/constants/enums.dart deleted file mode 100644 index e7aeb95..0000000 --- a/lib/src/constants/enums.dart +++ /dev/null @@ -1 +0,0 @@ -enum Shape { Rectangle, Circular, None } diff --git a/pubspec.lock b/pubspec.lock index b55f540..010beab 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: