From 127a7153555ac6220434e6831cfb6b0fd80f92f6 Mon Sep 17 00:00:00 2001 From: Lim Chee Kin Date: Wed, 13 Dec 2023 14:23:53 +0800 Subject: [PATCH] feat: added conditional import to support build for mobile --- .../lib/surrealdb_console_screen.dart | 27 +++++-------------- .../lib/surrealdb_console_widget_mobile.dart | 21 +++++++++++++++ ...dart => surrealdb_console_widget_web.dart} | 0 3 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 surrealdb_console/lib/surrealdb_console_widget_mobile.dart rename surrealdb_console/lib/{surrealdb_console_widget.dart => surrealdb_console_widget_web.dart} (100%) diff --git a/surrealdb_console/lib/surrealdb_console_screen.dart b/surrealdb_console/lib/surrealdb_console_screen.dart index 827f79b..3952bc6 100644 --- a/surrealdb_console/lib/surrealdb_console_screen.dart +++ b/surrealdb_console/lib/surrealdb_console_screen.dart @@ -1,7 +1,7 @@ -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:showcase_view/showcase_view.dart'; -import 'package:surrealdb_console/surrealdb_console_widget.dart'; +import 'package:surrealdb_console/surrealdb_console_widget_mobile.dart' + if (dart.library.html) 'package:surrealdb_console/surrealdb_console_widget_web.dart'; class SurrealdbConsoleScreen extends StatelessWidget { const SurrealdbConsoleScreen({Key? key}) : super(key: key); @@ -19,13 +19,11 @@ class SurrealdbConsoleScreen extends StatelessWidget { Widget build(BuildContext context) { return const ShowcaseView( title: 'SurrealDB Console', - widget: kIsWeb - ? SurrealdbConsoleWidget( - endpoint: 'indxdb://test', - ns: 'test', - db: 'test', - ) - : SurrealdbConsoleWebOnly(), + widget: SurrealdbConsoleWidget( + endpoint: 'indxdb://test', + ns: 'test', + db: 'test', + ), owner: owner, repository: repository, ref: branch, @@ -41,14 +39,3 @@ class SurrealdbConsoleScreen extends StatelessWidget { ); } } - -class SurrealdbConsoleWebOnly extends StatelessWidget { - const SurrealdbConsoleWebOnly({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return const Center( - child: Text('Surrealdb Console is working in web only!'), - ); - } -} diff --git a/surrealdb_console/lib/surrealdb_console_widget_mobile.dart b/surrealdb_console/lib/surrealdb_console_widget_mobile.dart new file mode 100644 index 0000000..525353f --- /dev/null +++ b/surrealdb_console/lib/surrealdb_console_widget_mobile.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; + +class SurrealdbConsoleWidget extends StatelessWidget { + const SurrealdbConsoleWidget({ + required this.endpoint, + this.ns, + this.db, + super.key, + }); + + final String endpoint; + final String? ns; + final String? db; + + @override + Widget build(BuildContext context) { + return const Center( + child: Text('Surrealdb Console is working in web only!'), + ); + } +} diff --git a/surrealdb_console/lib/surrealdb_console_widget.dart b/surrealdb_console/lib/surrealdb_console_widget_web.dart similarity index 100% rename from surrealdb_console/lib/surrealdb_console_widget.dart rename to surrealdb_console/lib/surrealdb_console_widget_web.dart