diff --git a/example/lib/src/callscreen.dart b/example/lib/src/callscreen.dart index 1d6bba56..9fbb7c14 100644 --- a/example/lib/src/callscreen.dart +++ b/example/lib/src/callscreen.dart @@ -655,7 +655,7 @@ class _MyCallScreenWidget extends State return Scaffold( appBar: AppBar( automaticallyImplyLeading: false, - title: Text('[$direction] ${EnumHelper.getName(_state)}'), + title: Text('[$direction] ${_state.name}'), ), body: _buildContent(), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, diff --git a/example/lib/src/dialpad.dart b/example/lib/src/dialpad.dart index 6ec93de6..0b5b6e0a 100644 --- a/example/lib/src/dialpad.dart +++ b/example/lib/src/dialpad.dart @@ -321,7 +321,7 @@ class _MyDialPadWidget extends State SizedBox(height: 8), Center( child: Text( - 'Register Status: ${EnumHelper.getName(helper!.registerState.state)}', + 'Register Status: ${helper!.registerState.state?.name ?? ''}', style: TextStyle(fontSize: 18, color: textColor), ), ), diff --git a/example/lib/src/register.dart b/example/lib/src/register.dart index fecc2471..d6071440 100644 --- a/example/lib/src/register.dart +++ b/example/lib/src/register.dart @@ -182,7 +182,7 @@ class _MyRegisterWidget extends State children: [ Center( child: Text( - 'Register Status: ${EnumHelper.getName(_registerState.state)}', + 'Register Status: ${_registerState.state?.name ?? ''}', style: TextStyle(fontSize: 18, color: textColor), ), ), diff --git a/lib/sip_ua.dart b/lib/sip_ua.dart index 8fe2256f..7c37f449 100644 --- a/lib/sip_ua.dart +++ b/lib/sip_ua.dart @@ -1,4 +1,3 @@ -export 'src/enum_helper.dart'; export 'src/enums.dart'; export 'src/sip_message.dart'; export 'src/sip_ua_helper.dart'; diff --git a/lib/src/enum_helper.dart b/lib/src/enum_helper.dart deleted file mode 100644 index 55f8949e..00000000 --- a/lib/src/enum_helper.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:recase/recase.dart'; - -/// -/// Provides a collection of methods that help when working with -/// enums. -/// -class EnumHelper { - static T getByIndex(List values, int index) { - return values.elementAt(index - 1); - } - - static int getIndexOf(List values, T value) { - return values.indexOf(value); - } - - /// - /// Returns the Enum name without the enum class. - /// e.g. DayName.Wednesday becomes Wednesday. - /// By default we recase the value to Title Case. - /// You can pass an alternate method to control the format. - /// - static String getName(T enumValue, - {String Function(String value) recase = reCase}) { - String name = enumValue.toString(); - int period = name.indexOf('.'); - - return recase(name.substring(period + 1)); - } - - static String reCase(String value) { - return ReCase(value).titleCase; - } - - static T getEnum(String enumName, List values) { - String cleanedName = reCase(enumName); - for (int i = 0; i < values.length; i++) { - if (cleanedName == getName(values[i])) { - return values[i]; - } - } - throw Exception("$cleanedName doesn't exist in the list of enums $values"); - } -} diff --git a/lib/src/logger.dart b/lib/src/logger.dart index d8989695..21169d23 100644 --- a/lib/src/logger.dart +++ b/lib/src/logger.dart @@ -1,7 +1,6 @@ import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; -import 'enum_helper.dart'; import 'stack_trace_nj.dart'; Logger logger = Log(); @@ -41,8 +40,7 @@ class MyLogPrinter extends LogPrinter { @override List log(LogEvent event) { - if (EnumHelper.getIndexOf(Level.values, Log._loggingLevel) > - EnumHelper.getIndexOf(Level.values, event.level)) { + if (Log._loggingLevel.index > event.level.index) { // don't log events where the log level is set higher return []; } diff --git a/pubspec.yaml b/pubspec.yaml index 6535e6de..ae977034 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,6 @@ dependencies: logger: ^2.0.2+1 path: ^1.6.4 random_string: ^2.3.1 - recase: ^4.1.0 sdp_transform: ^0.3.2 text: ^0.2.0 uuid: ^4.2.1