Navaron Bracke

move CalendarEvent to its own file

@@ -14,6 +14,7 @@ export 'src/mobile_scanner_controller.dart'; @@ -14,6 +14,7 @@ export 'src/mobile_scanner_controller.dart';
14 export 'src/mobile_scanner_exception.dart'; 14 export 'src/mobile_scanner_exception.dart';
15 export 'src/objects/barcode.dart'; 15 export 'src/objects/barcode.dart';
16 export 'src/objects/barcode_capture.dart'; 16 export 'src/objects/barcode_capture.dart';
  17 +export 'src/objects/calendar_event.dart';
17 export 'src/objects/driver_license.dart'; 18 export 'src/objects/driver_license.dart';
18 export 'src/objects/email.dart'; 19 export 'src/objects/email.dart';
19 export 'src/objects/mobile_scanner_arguments.dart'; 20 export 'src/objects/mobile_scanner_arguments.dart';
@@ -7,6 +7,7 @@ import 'package:mobile_scanner/src/enums/barcode_format.dart'; @@ -7,6 +7,7 @@ import 'package:mobile_scanner/src/enums/barcode_format.dart';
7 import 'package:mobile_scanner/src/enums/barcode_type.dart'; 7 import 'package:mobile_scanner/src/enums/barcode_type.dart';
8 import 'package:mobile_scanner/src/enums/encryption_type.dart'; 8 import 'package:mobile_scanner/src/enums/encryption_type.dart';
9 import 'package:mobile_scanner/src/enums/phone_type.dart'; 9 import 'package:mobile_scanner/src/enums/phone_type.dart';
  10 +import 'package:mobile_scanner/src/objects/calendar_event.dart';
10 import 'package:mobile_scanner/src/objects/driver_license.dart'; 11 import 'package:mobile_scanner/src/objects/driver_license.dart';
11 import 'package:mobile_scanner/src/objects/email.dart'; 12 import 'package:mobile_scanner/src/objects/email.dart';
12 13
@@ -118,58 +119,6 @@ class Barcode { @@ -118,58 +119,6 @@ class Barcode {
118 wifi = toWiFi(data['wifi'] as Map?); 119 wifi = toWiFi(data['wifi'] as Map?);
119 } 120 }
120 121
121 -/// A calendar event extracted from QRCode.  
122 -class CalendarEvent {  
123 - /// Gets the description of the calendar event.  
124 - ///  
125 - /// Returns null if not available.  
126 - final String? description;  
127 -  
128 - /// Gets the start date time of the calendar event.  
129 - ///  
130 - /// Returns null if not available.  
131 - final DateTime? start;  
132 -  
133 - /// Gets the end date time of the calendar event.  
134 - ///  
135 - /// Returns null if not available.  
136 - final DateTime? end;  
137 -  
138 - /// Gets the location of the calendar event.  
139 - ///  
140 - /// Returns null if not available.  
141 - final String? location;  
142 -  
143 - /// Gets the organizer of the calendar event.  
144 - ///  
145 - /// Returns null if not available.  
146 - final String? organizer;  
147 -  
148 - /// Gets the status of the calendar event.  
149 - ///  
150 - /// Returns null if not available.  
151 - final String? status;  
152 -  
153 - /// Gets the summary of the calendar event.  
154 - ///  
155 - /// Returns null if not available.  
156 - final String? summary;  
157 -  
158 - /// Create a [CalendarEvent] from native data.  
159 - CalendarEvent.fromNative(Map data)  
160 - : description = data['description'] as String?,  
161 - start = data['start'] != null  
162 - ? DateTime.tryParse(data['start'] as String)  
163 - : null,  
164 - end = data['end'] != null  
165 - ? DateTime.tryParse(data['end'] as String)  
166 - : null,  
167 - location = data['location'] as String?,  
168 - organizer = data['organizer'] as String?,  
169 - status = data['status'] as String?,  
170 - summary = data['summary'] as String?;  
171 -}  
172 -  
173 /// A person's or organization's business card. For example a VCARD. 122 /// A person's or organization's business card. For example a VCARD.
174 class ContactInfo { 123 class ContactInfo {
175 /// Gets contact person's addresses. 124 /// Gets contact person's addresses.
  1 +/// A calendar event extracted from a QRCode.
  2 +class CalendarEvent {
  3 + /// Create a new [CalendarEvent] instance.
  4 + const CalendarEvent({
  5 + this.description,
  6 + this.start,
  7 + this.end,
  8 + this.location,
  9 + this.organizer,
  10 + this.status,
  11 + this.summary,
  12 + });
  13 +
  14 + /// Create a new [CalendarEvent] instance from a map.
  15 + factory CalendarEvent.fromNative(Map<Object?, Object?> data) {
  16 + return CalendarEvent(
  17 + description: data['description'] as String?,
  18 + start: DateTime.tryParse(data['start'] as String? ?? ''),
  19 + end: DateTime.tryParse(data['end'] as String? ?? ''),
  20 + location: data['location'] as String?,
  21 + organizer: data['organizer'] as String?,
  22 + status: data['status'] as String?,
  23 + summary: data['summary'] as String?,
  24 + );
  25 + }
  26 +
  27 + /// The description of the calendar event.
  28 + final String? description;
  29 +
  30 + /// The start time of the calendar event.
  31 + final DateTime? start;
  32 +
  33 + /// The end time of the calendar event.
  34 + final DateTime? end;
  35 +
  36 + /// The location of the calendar event.
  37 + final String? location;
  38 +
  39 + /// The organizer of the calendar event.
  40 + final String? organizer;
  41 +
  42 + /// The status of the calendar event.
  43 + final String? status;
  44 +
  45 + /// The summary of the calendar event.
  46 + final String? summary;
  47 +}