Skip to content

Commit

Permalink
add: refusing download if platform is web
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericles-Porty committed Mar 12, 2024
1 parent ccba771 commit 9b15c59
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Makefile for deploying the Flutter web projects to GitHub

BASE_HREF = /$(OUTPUT)/
# Replace this with your GitHub username
GITHUB_USER = Ericles-Porty
GITHUB_REPO = https://github.com/$(GITHUB_USER)/$(OUTPUT)
BUILD_VERSION := $(shell grep 'version:' pubspec.yaml | awk '{print $$2}')

# Deploy the Flutter web project to GitHub
deploy:
ifndef OUTPUT
$(error OUTPUT is not set. Usage: make deploy OUTPUT=<output_repo_name>)
endif

@echo "Clean existing repository"
flutter clean

@echo "Getting packages..."
flutter pub get

@echo "Generating the web folder..."
flutter create . --platform web

@echo "Building for web..."
flutter build web --base-href $(BASE_HREF) --release

@echo "Deploying to git repository"
cd build/web && \
git init && \
git add . && \
git commit -m "Deploy Version $(BUILD_VERSION)" && \
git branch -M main && \
git remote add origin $(GITHUB_REPO) && \
git push -u -f origin main

@echo "✅ Finished deploy: $(GITHUB_REPO)"
@echo "🚀 Flutter web URL: https://$(GITHUB_USER).github.io/$(OUTPUT)/"

.PHONY: deploy
28 changes: 28 additions & 0 deletions lib/src/components/my_dialogs.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:updater_project/src/components/my_snack_bars.dart';
import 'package:updater_project/src/controllers/download_progress_controller.dart';
Expand Down Expand Up @@ -112,6 +115,11 @@ Future<void> _handleVersionSelection(BuildContext context, String version) async
}

downloadingShowDialog(BuildContext context) {
if (kIsWeb) {
_webPlatformAlertDialog(context);
return;
}

showDialog(
barrierDismissible: false,
context: context,
Expand Down Expand Up @@ -151,6 +159,26 @@ downloadingShowDialog(BuildContext context) {
);
}

Future<dynamic> _webPlatformAlertDialog(BuildContext context) {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Feature not available on web'),
content: const Text(
'Sorry, but this feature is just available on mobile and desktop platforms. Please try again on a different platform.'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Close'),
),
],
);
});
}

Future<bool> getUserOptionDialog(BuildContext context) async {
final option = await showDialog(
context: context,
Expand Down

0 comments on commit 9b15c59

Please sign in to comment.