Skip to content

Commit

Permalink
update for linux version
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Wei committed Mar 7, 2021
1 parent ac3f694 commit f07b15c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@ const GOOGLEPLAY_URL =
const GITHUB_URL = 'https://github.com/X-Wei/flutter_catalog';
const AUTHOR_SITE = 'http://x-wei.github.io';

// Whether the app is running on mobile phones (Android/iOS)
// ! `Platform` is not available on web !
final kIsOnMobile = kIsWeb || Platform.isAndroid || Platform.isIOS;

/// Adapted from https://www.flutterclutter.dev/flutter/tutorials/how-to-detect-what-platform-a-flutter-app-is-running-on/2020/127/
final kPlatformType = getCurrentPlatformType();
// Whether the app is running on mobile phones (Android/iOS)
final kIsOnMobile =
{PlatformType.Android, PlatformType.iOS}.contains(kPlatformType);

/// ! Adapted from https://www.flutterclutter.dev/flutter/tutorials/how-to-detect-what-platform-a-flutter-app-is-running-on/2020/127/
enum PlatformType { Web, iOS, Android, MacOS, Fuchsia, Linux, Windows, Unknown }

PlatformType getCurrentPlatformType() {
// ! `Platform` is not available on web, so we must check web first.
if (kIsWeb) {
return PlatformType.Web;
}
Expand Down
2 changes: 2 additions & 0 deletions lib/generated_plugin_registrant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:cloud_firestore_web/cloud_firestore_web.dart';
import 'package:firebase_analytics_web/firebase_analytics_web.dart';
import 'package:firebase_auth_web/firebase_auth_web.dart';
import 'package:firebase_core_web/firebase_core_web.dart';
import 'package:firebase_storage_web/firebase_storage_web.dart';
import 'package:fluttertoast/fluttertoast_web.dart';
import 'package:google_sign_in_web/google_sign_in_web.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';
Expand All @@ -22,6 +23,7 @@ void registerPlugins(Registrar registrar) {
FirebaseAnalyticsWeb.registerWith(registrar);
FirebaseAuthWeb.registerWith(registrar);
FirebaseCoreWeb.registerWith(registrar);
FirebaseStorageWeb.registerWith(registrar);
FluttertoastWebPlugin.registerWith(registrar);
GoogleSignInPlugin.registerWith(registrar);
SharedPreferencesPlugin.registerWith(registrar);
Expand Down
4 changes: 3 additions & 1 deletion lib/my_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:url_launcher/url_launcher.dart' as url_launcher;
import 'package:widget_with_codeview/widget_with_codeview.dart';

import './constants.dart'
show APP_NAME, APP_VERSION, GITHUB_URL, kAppIcon, kIsOnMobile;
show APP_NAME, APP_VERSION, GITHUB_URL, kAppIcon, kIsOnMobile, PlatformType;
import './my_app_settings.dart';
import './my_route_search_delegate.dart';
import './routes/about.dart';
Expand All @@ -28,6 +28,7 @@ class MyRoute extends StatelessWidget {
final Map<String, String> links;
// Route name of a page.
final String _routeName;
final Iterable<PlatformType> supportedPlatforms;

const MyRoute({
Key key,
Expand All @@ -37,6 +38,7 @@ class MyRoute extends StatelessWidget {
this.description,
this.links,
String routeName,
this.supportedPlatforms = PlatformType.values,
}) : _title = title,
_routeName = routeName,
super(key: key);
Expand Down

0 comments on commit f07b15c

Please sign in to comment.