diff --git a/examples/flutter_gallery/lib/demo/video_demo.dart b/examples/flutter_gallery/lib/demo/video_demo.dart index 1fb5a01a1c..f291be55a4 100644 --- a/examples/flutter_gallery/lib/demo/video_demo.dart +++ b/examples/flutter_gallery/lib/demo/video_demo.dart @@ -3,9 +3,11 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:io'; import 'package:connectivity/connectivity.dart'; import 'package:flutter/material.dart'; import 'package:video_player/video_player.dart'; +import 'package:device_info/device_info.dart'; // TODO(sigurdm): These should not be stored here. const String butterflyUri = @@ -348,6 +350,12 @@ class VideoDemo extends StatefulWidget { _VideoDemoState createState() => new _VideoDemoState(); } +final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin(); + +Future isIOSSimulator() async { + return Platform.isIOS && !(await deviceInfoPlugin.iosInfo).isPhysicalDevice; +} + class _VideoDemoState extends State with SingleTickerProviderStateMixin { final VideoPlayerController butterflyController = new VideoPlayerController( @@ -359,6 +367,7 @@ class _VideoDemoState extends State final GlobalKey scaffoldKey = new GlobalKey(); final Completer connectedCompleter = new Completer(); + bool isSupported = true; @override void initState() { @@ -375,6 +384,9 @@ class _VideoDemoState extends State initController(butterflyController); initController(beeController); + isIOSSimulator().then((bool result) { + isSupported = !result; + }); } @override @@ -391,24 +403,30 @@ class _VideoDemoState extends State appBar: new AppBar( title: const Text('Videos'), ), - body: new ConnectivityOverlay( - child: new ListView( - children: [ - new VideoCard( - title: 'Butterfly', - subtitle: '… flutters by', - controller: butterflyController, + body: (isSupported) + ? new ConnectivityOverlay( + child: new ListView( + children: [ + new VideoCard( + title: 'Butterfly', + subtitle: '… flutters by', + controller: butterflyController, + ), + new VideoCard( + title: 'Bee', + subtitle: '… gently buzzing', + controller: beeController, + ), + ], + ), + connectedCompleter: connectedCompleter, + scaffoldKey: scaffoldKey, + ) + : const Center( + child: const Text( + 'The video demo is not supported on the iOS Simulator.', + ), ), - new VideoCard( - title: 'Bee', - subtitle: '… gently buzzing', - controller: beeController, - ), - ], - ), - connectedCompleter: connectedCompleter, - scaffoldKey: scaffoldKey, - ), ); } } diff --git a/examples/flutter_gallery/pubspec.yaml b/examples/flutter_gallery/pubspec.yaml index ff22482173..cee237c896 100644 --- a/examples/flutter_gallery/pubspec.yaml +++ b/examples/flutter_gallery/pubspec.yaml @@ -3,6 +3,7 @@ dependencies: flutter: sdk: flutter collection: 1.14.3 + device_info: 0.0.5 intl: 0.15.2 connectivity: 0.1.0 string_scanner: 1.0.2