File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
demos/supabase-todolist/lib Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11import 'package:camera/camera.dart' ;
22import 'package:flutter/widgets.dart' ;
3+ import 'package:powersync_flutter_demo/powersync.dart' ;
34
45late final CameraDescription ? camera;
56
@@ -8,8 +9,14 @@ Future<CameraDescription?> setupCamera() async {
89 // can be called before `runApp()`
910 WidgetsFlutterBinding .ensureInitialized ();
1011 // Obtain a list of the available cameras on the device.
11- final cameras = await availableCameras ();
12- // Get a specific camera from the list of available cameras.
13- final camera = cameras.isNotEmpty ? cameras.first : null ;
14- return camera;
12+ try {
13+ final cameras = await availableCameras ();
14+ // Get a specific camera from the list of available cameras.
15+ final camera = cameras.isNotEmpty ? cameras.first : null ;
16+ return camera;
17+ } catch (e) {
18+ // Camera is not supported on all platforms
19+ log.warning ('Failed to setup camera: $e ' );
20+ return null ;
21+ }
1522}
Original file line number Diff line number Diff line change 11import 'package:flutter/material.dart' ;
22import 'package:powersync_flutter_demo/app_config.dart' ;
3+ import 'package:powersync_flutter_demo/attachments/camera_helpers.dart' ;
34import 'package:powersync_flutter_demo/attachments/photo_widget.dart' ;
45import 'package:powersync_flutter_demo/attachments/queue.dart' ;
56
@@ -53,7 +54,7 @@ class TodoItemWidget extends StatelessWidget {
5354 onPressed: () async => await deleteTodo (todo),
5455 tooltip: 'Delete Item' ,
5556 ),
56- AppConfig .supabaseStorageBucket.isEmpty
57+ AppConfig .supabaseStorageBucket.isEmpty || camera == null
5758 ? Container ()
5859 : PhotoWidget (todo: todo),
5960 ],
You can’t perform that action at this time.
0 commit comments