Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-10-23 17:47:19 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1581a459c4bb8590de2292929ac15ee2d552f2bc
1581a459
1 parent
7056288b
move ContactInfo to its own file
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
56 deletions
CHANGELOG.md
lib/mobile_scanner.dart
lib/src/objects/barcode.dart
lib/src/objects/contact_info.dart
CHANGELOG.md
View file @
1581a45
...
...
@@ -3,6 +3,7 @@ Improvements:
*
The
`type` of an `Email`
is now non-null.
*
The
`phoneNumber` of an `SMS`
is now non-null.
*
The
`latitude` and `longitude` of a `GeoPoint`
are now non-null.
*
The
`phones` and `urls` of `ContactInfo`
are now non-null.
## 3.5.0
New Features:
...
...
lib/mobile_scanner.dart
View file @
1581a45
...
...
@@ -15,6 +15,7 @@ export 'src/mobile_scanner_exception.dart';
export
'src/objects/barcode.dart'
;
export
'src/objects/barcode_capture.dart'
;
export
'src/objects/calendar_event.dart'
;
export
'src/objects/contact_info.dart'
;
export
'src/objects/driver_license.dart'
;
export
'src/objects/email.dart'
;
export
'src/objects/geo_point.dart'
;
...
...
lib/src/objects/barcode.dart
View file @
1581a45
...
...
@@ -7,6 +7,7 @@ import 'package:mobile_scanner/src/enums/barcode_format.dart';
import
'package:mobile_scanner/src/enums/barcode_type.dart'
;
import
'package:mobile_scanner/src/enums/phone_type.dart'
;
import
'package:mobile_scanner/src/objects/calendar_event.dart'
;
import
'package:mobile_scanner/src/objects/contact_info.dart'
;
import
'package:mobile_scanner/src/objects/driver_license.dart'
;
import
'package:mobile_scanner/src/objects/email.dart'
;
import
'package:mobile_scanner/src/objects/geo_point.dart'
;
...
...
@@ -121,62 +122,6 @@ class Barcode {
wifi
=
toWiFi
(
data
[
'wifi'
]
as
Map
?);
}
/// A person's or organization's business card. For example a VCARD.
class
ContactInfo
{
/// Gets contact person's addresses.
///
/// Returns an empty list if nothing found.
final
List
<
Address
>
addresses
;
/// Gets contact person's emails.
///
/// Returns an empty list if nothing found.
final
List
<
Email
>
emails
;
/// Gets contact person's name.
///
/// Returns null if not available.
final
PersonName
?
name
;
/// Gets contact person's organization.
///
/// Returns null if not available.
final
String
?
organization
;
/// Gets contact person's phones.
///
/// Returns an empty list if nothing found.
final
List
<
Phone
>?
phones
;
/// Gets contact person's title.
///
/// Returns null if not available.
final
String
?
title
;
/// Gets contact person's urls.
///
/// Returns an empty list if nothing found.
final
List
<
String
>?
urls
;
/// Create a [ContactInfo] from native data.
ContactInfo
.
fromNative
(
Map
data
)
:
addresses
=
List
.
unmodifiable
(
(
data
[
'addresses'
]
as
List
?
??
[])
.
cast
<
Map
>()
.
map
(
Address
.
fromNative
),
),
emails
=
List
.
unmodifiable
(
(
data
[
'emails'
]
as
List
?
??
[]).
cast
<
Map
>().
map
(
Email
.
fromNative
),
),
name
=
toName
(
data
[
'name'
]
as
Map
?),
organization
=
data
[
'organization'
]
as
String
?,
phones
=
List
.
unmodifiable
(
(
data
[
'phones'
]
as
List
?
??
[]).
cast
<
Map
>().
map
(
Phone
.
fromNative
),
),
title
=
data
[
'title'
]
as
String
?,
urls
=
List
.
unmodifiable
((
data
[
'urls'
]
as
List
?
??
[]).
cast
<
String
>());
}
/// An address.
class
Address
{
/// Gets formatted address, multiple lines when appropriate. This field always contains at least one line.
...
...
lib/src/objects/contact_info.dart
0 → 100644
View file @
1581a45
import
'package:mobile_scanner/src/objects/barcode.dart'
;
import
'package:mobile_scanner/src/objects/email.dart'
;
/// A person's or organization's business card.
/// For example a VCARD.
class
ContactInfo
{
/// Create a new [ContactInfo] instance.
const
ContactInfo
({
this
.
addresses
=
const
<
Address
>[],
this
.
emails
=
const
<
Email
>[],
this
.
name
,
this
.
organization
,
this
.
phones
=
const
<
Phone
>[],
this
.
title
,
this
.
urls
=
const
<
String
>[],
});
/// Create a new [ContactInfo] instance from a map.
factory
ContactInfo
.
fromNative
(
Map
<
Object
?,
Object
?>
data
)
{
final
List
<
Object
?>?
addresses
=
data
[
'addresses'
]
as
List
<
Object
?>?;
final
List
<
Object
?>?
emails
=
data
[
'emails'
]
as
List
<
Object
?>?;
final
List
<
Object
?>?
phones
=
data
[
'phones'
]
as
List
<
Object
?>?;
final
List
<
Object
?>?
urls
=
data
[
'urls'
]
as
List
<
Object
?>?;
final
Map
<
Object
?,
Object
?>?
name
=
data
[
'name'
]
as
Map
<
Object
?,
Object
?>?;
return
ContactInfo
(
addresses:
addresses
==
null
?
const
<
Address
>[]
:
List
.
unmodifiable
(
addresses
.
cast
<
Map
<
Object
?,
Object
?>>().
map
(
Address
.
fromNative
),
),
emails:
emails
==
null
?
const
<
Email
>[]
:
List
.
unmodifiable
(
emails
.
cast
<
Map
<
Object
?,
Object
?>>().
map
(
Email
.
fromNative
),
),
name:
name
==
null
?
null
:
PersonName
.
fromNative
(
name
),
organization:
data
[
'organization'
]
as
String
?,
phones:
phones
==
null
?
const
<
Phone
>[]
:
List
.
unmodifiable
(
phones
.
cast
<
Map
<
Object
?,
Object
?>>().
map
(
Phone
.
fromNative
),
),
title:
data
[
'title'
]
as
String
?,
urls:
urls
==
null
?
const
<
String
>[]
:
List
.
unmodifiable
(
urls
.
cast
<
String
>()),
);
}
/// The list of addresses for the person or organisation.
final
List
<
Address
>
addresses
;
/// The list of email addresses for the person or organisation.
final
List
<
Email
>
emails
;
/// The name of the contact person.
final
PersonName
?
name
;
/// The name of the organization.
final
String
?
organization
;
/// The available phone numbers for the contact person or organisation.
final
List
<
Phone
>
phones
;
/// The contact person's title.
final
String
?
title
;
/// The urls associated with the contact person or organisation.
final
List
<
String
>
urls
;
}
...
...
Please
register
or
login
to post a comment