mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Adds ai_recipe_generation sample (#2242)
Adding the demo app from my I/O talk. Because AI. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. --------- Co-authored-by: Brett Morgan <brett.morgan@gmail.com>
This commit is contained in:
39
ai_recipe_generation/lib/util/device_info.dart
Normal file
39
ai_recipe_generation/lib/util/device_info.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class DeviceInfo {
|
||||
static Future<BaseDeviceInfo> initialize(DeviceInfoPlugin plugin) async {
|
||||
if (kIsWeb) {
|
||||
return await plugin.webBrowserInfo;
|
||||
}
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
return await plugin.androidInfo;
|
||||
case TargetPlatform.iOS:
|
||||
return await plugin.iosInfo;
|
||||
case TargetPlatform.macOS:
|
||||
return plugin.macOsInfo;
|
||||
case TargetPlatform.windows:
|
||||
return await plugin.windowsInfo;
|
||||
case TargetPlatform.linux:
|
||||
return await plugin.linuxInfo;
|
||||
default:
|
||||
throw UnsupportedError(
|
||||
'Device info not supported for this platform',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static bool isPhysicalDeviceWithCamera(BaseDeviceInfo deviceInfo) {
|
||||
if (deviceInfo is! IosDeviceInfo && deviceInfo is! AndroidDeviceInfo) {
|
||||
return false;
|
||||
}
|
||||
if (deviceInfo is IosDeviceInfo && deviceInfo.isPhysicalDevice) {
|
||||
return true;
|
||||
}
|
||||
if (deviceInfo is AndroidDeviceInfo && deviceInfo.isPhysicalDevice) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user