Skip to content

Commit

Permalink
Merge pull request #183 from wiredashio/multiple_attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy authored Mar 2, 2022
2 parents dcab425 + 8794238 commit c8740b2
Show file tree
Hide file tree
Showing 25 changed files with 1,607 additions and 1,356 deletions.
2 changes: 1 addition & 1 deletion lib/src/common/build_info/device_id_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DeviceIdGenerator {
}

// first time generation or fallback in case of sharedPrefs error
final _deviceId = uuidV4.generate();
final _deviceId = const UuidV4Generator().generate();
try {
final prefs =
await SharedPreferences.getInstance().timeout(_sharedPrefsTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class _DartHtmlDeviceInfoGenerator implements DeviceInfoGenerator {
final SingletonFlutterWindow window;

@override
DeviceInfo generate() {
FlutterDeviceInfo generate() {
final base = DeviceInfoGenerator.baseDeviceInfo(window);
return base.copyWith(
userAgent: html.window.navigator.userAgent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class _DartIoDeviceInfoGenerator implements DeviceInfoGenerator {
final SingletonFlutterWindow window;

@override
DeviceInfo generate() {
FlutterDeviceInfo generate() {
final base = DeviceInfoGenerator.baseDeviceInfo(window);
return base.copyWith(
platformOS: Platform.operatingSystem,
Expand Down
16 changes: 11 additions & 5 deletions lib/src/common/device_info/device_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import 'package:flutter/widgets.dart';

export 'dart:ui' show Brightness;

class DeviceInfo {
/// All information we can gather from the Flutter Framework about the
/// device/window/canvas
///
/// Created by following implementations
/// - [_DartHtmlDeviceInfoGenerator]
/// - [_DartIoDeviceInfoGenerator]
class FlutterDeviceInfo {
/// The primary locale enabled on the device
///
/// https://api.flutter.dev/flutter/dart-ui/SingletonFlutterWindow/locale.html
Expand Down Expand Up @@ -78,7 +84,7 @@ class DeviceInfo {
/// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
final String? userAgent;

const DeviceInfo({
const FlutterDeviceInfo({
required this.platformLocale,
required this.platformSupportedLocales,
required this.padding,
Expand All @@ -95,7 +101,7 @@ class DeviceInfo {
required this.gestureInsets,
});

DeviceInfo copyWith({
FlutterDeviceInfo copyWith({
String? deviceId,
String? platformLocale,
List<String>? platformSupportedLocales,
Expand All @@ -112,7 +118,7 @@ class DeviceInfo {
Brightness? platformBrightness,
WindowPadding? gestureInsets,
}) {
return DeviceInfo(
return FlutterDeviceInfo(
platformLocale: platformLocale ?? this.platformLocale,
platformSupportedLocales:
platformSupportedLocales ?? this.platformSupportedLocales,
Expand Down Expand Up @@ -154,7 +160,7 @@ class DeviceInfo {
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is DeviceInfo &&
(other is FlutterDeviceInfo &&
runtimeType == other.runtimeType &&
platformLocale == other.platformLocale &&
listEquals(
Expand Down
9 changes: 5 additions & 4 deletions lib/src/common/device_info/device_info_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ abstract class DeviceInfoGenerator {
return createDeviceInfoGenerator(window);
}

/// Collection of all [DeviceInfo] shared between all platforms
static DeviceInfo baseDeviceInfo(SingletonFlutterWindow window) {
/// Collection of all [FlutterDeviceInfo] shared between all platforms
static FlutterDeviceInfo baseDeviceInfo(SingletonFlutterWindow window) {
Locale windowLocale() {
// Flutter 1.26 (2.0.1) returns `Locale?`, 1.27 `Locale`
// ignore: unnecessary_nullable_for_final_variable_declarations
Expand All @@ -31,7 +31,7 @@ abstract class DeviceInfoGenerator {
return locales ?? [];
}

return DeviceInfo(
return FlutterDeviceInfo(
platformLocale: windowLocale().toLanguageTag(),
platformSupportedLocales:
windowLocales().map((it) => it.toLanguageTag()).toList(),
Expand All @@ -46,5 +46,6 @@ abstract class DeviceInfoGenerator {
);
}

DeviceInfo generate();
/// Collects information from Flutter
FlutterDeviceInfo generate();
}
Loading

0 comments on commit c8740b2

Please sign in to comment.