Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/stac/lib/src/framework/stac.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -150,6 +151,7 @@ class Stac {
try {
if (json != null) {
Map<String, dynamic>? jsonVersion = json['version'];
final platform = json['platform'];

/// Check if has version and buildNumber is not null
if (jsonVersion != null && StacRegistry.instance.buildNumber != null) {
Expand All @@ -164,6 +166,30 @@ class Stac {
}
}

/// Check if platform is specified and validate
if (platform != null) {
final currentPlatform = Platform.operatingSystem;
bool isPlatformSupported = false;
List<String> supportedPlatforms = [];

// Check if platform is a list or a single string
if (platform is List) {
supportedPlatforms = platform.map((e) => e.toString()).toList();
isPlatformSupported = supportedPlatforms.contains(currentPlatform);
} else if (platform is String) {
supportedPlatforms.add(platform);
isPlatformSupported = platform == currentPlatform;
}

// If platform is not supported, log and return null
if (!isPlatformSupported) {
final platformsStr = supportedPlatforms.join(', ');
Log.w(
'Widget not supported on platform [$currentPlatform]. Only available for: $platformsStr');
return null;
}
}

String widgetType = json['type'];
StacParser? stacParser = StacRegistry.instance.getParser(widgetType);

Expand Down