LCOV - code coverage report
Current view: top level - lib/model - data_type.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 16 16 100.0 %
Date: 2021-09-29 11:41:23 Functions: 0 0 -

          Line data    Source code
       1             : part of apptive_grid_model;
       2             : 
       3             : /// The Data Types that are available in Apptive grid
       4          33 : enum DataType {
       5             :   /// Type to display [String]
       6             :   text,
       7             : 
       8             :   /// Type to display [DateTime]
       9             :   dateTime,
      10             : 
      11             :   /// Type to display [DateTime] without the option to adjust the Time part
      12             :   date,
      13             : 
      14             :   /// Type to display [int] numbers
      15             :   integer,
      16             : 
      17             :   /// Type to display [double] decimal numbers
      18             :   decimal,
      19             : 
      20             :   /// Type to display [bool] values
      21             :   checkbox,
      22             : 
      23             :   /// Type to display enum values
      24             :   selectionBox,
      25             : 
      26             :   /// Type to display CrossReference Values
      27             :   crossReference,
      28             : }
      29             : 
      30             : /// Returns [DataType] that matching a certain schema [schemaProperty]
      31             : ///
      32             : /// throws [ArgumentError] if DataType is not supported yet
      33           7 : DataType dataTypeFromSchemaProperty({
      34             :   required dynamic schemaProperty,
      35             : }) {
      36           7 :   final schemaType = schemaProperty['type'];
      37           7 :   final format = schemaProperty['format'];
      38             :   switch (schemaType) {
      39           7 :     case 'string':
      40           5 :       if (schemaProperty['enum'] != null) {
      41             :         return DataType.selectionBox;
      42             :       }
      43             :       switch (format) {
      44           4 :         case 'date-time':
      45             :           return DataType.dateTime;
      46           4 :         case 'date':
      47             :           return DataType.date;
      48             :       }
      49             :       return DataType.text;
      50           5 :     case 'integer':
      51             :       return DataType.integer;
      52           5 :     case 'number':
      53             :       return DataType.decimal;
      54           4 :     case 'boolean':
      55             :       return DataType.checkbox;
      56           3 :     case 'object':
      57           2 :       final objectType = schemaProperty['objectType'];
      58             :       switch (objectType) {
      59           2 :         case 'entityreference':
      60             :           return DataType.crossReference;
      61             :       }
      62             :   }
      63           1 :   throw ArgumentError(
      64           1 :     'No according DataType found for "$schemaType". Supported DataTypes are ${DataType.values}',
      65             :   );
      66             : }

Generated by: LCOV version 1.15