Merge pull request #6 from appwrite/fix-build-script
Simplify flutter starter by removing build script
This commit is contained in:
commit
8aa2aec2d6
@ -1,3 +0,0 @@
|
|||||||
APPWRITE_PROJECT_ID=
|
|
||||||
APPWRITE_PROJECT_NAME=
|
|
||||||
APPWRITE_PUBLIC_ENDPOINT=
|
|
||||||
33
README.md
33
README.md
@ -24,16 +24,39 @@ Alternatively, open the repository URL in `Android Studio` to clone it directly.
|
|||||||
## 🛠️ Development Guide
|
## 🛠️ Development Guide
|
||||||
|
|
||||||
1. **Configure Appwrite**
|
1. **Configure Appwrite**
|
||||||
Navigate to `lib/data/repository/appwrite_repository.dart` and update the values to match your
|
Open `lib/config/environment.dart` and update the values with your Appwrite project credentials:
|
||||||
Appwrite project credentials.
|
```dart
|
||||||
|
class Environment {
|
||||||
|
static const String appwriteEndpoint = '[appwriteEndpoint]';
|
||||||
|
static const String appwriteProjectId = '[appwriteProjectId]';
|
||||||
|
static const String appwriteProjectName = '[appwriteProjectName]';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
2. **Customize as Needed**
|
2. **Customize as Needed**
|
||||||
Modify the starter kit to suit your app's requirements. Adjust UI, features, or backend
|
Modify the starter kit to suit your app's requirements. Adjust UI, features, or backend
|
||||||
integrations as per your needs.
|
integrations as per your needs.
|
||||||
|
|
||||||
3. **Run the App**
|
3. **Run the App**
|
||||||
Select a target device (emulator or a connected physical device) in `Android Studio`, and
|
Select a target device and run the app:
|
||||||
click **Run** to start the app.
|
```bash
|
||||||
|
# List available devices
|
||||||
|
flutter devices
|
||||||
|
|
||||||
|
# Run on a specific device (replace 'device-id' with actual device)
|
||||||
|
flutter run -d device-id
|
||||||
|
|
||||||
|
# Examples:
|
||||||
|
flutter run -d chrome # Web
|
||||||
|
flutter run -d "iPhone 15" # iOS Simulator
|
||||||
|
flutter run -d emulator-5554 # Android Emulator
|
||||||
|
flutter run -d macos # macOS Desktop
|
||||||
|
```
|
||||||
|
|
||||||
|
**Build for Web:**
|
||||||
|
```bash
|
||||||
|
flutter build web
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -46,5 +69,5 @@ production : https://docs.flutter.dev/deployment
|
|||||||
|
|
||||||
## 💡 Additional Notes
|
## 💡 Additional Notes
|
||||||
|
|
||||||
- This starter project is designed to streamline your Android development with Appwrite.
|
- This starter project is designed to streamline your Flutter development with Appwrite.
|
||||||
- Refer to the [Appwrite Documentation](https://appwrite.io/docs) for detailed integration guidance.
|
- Refer to the [Appwrite Documentation](https://appwrite.io/docs) for detailed integration guidance.
|
||||||
29
build.sh
29
build.sh
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if .env file exists
|
|
||||||
if [ ! -f .env ]; then
|
|
||||||
{
|
|
||||||
echo "APPWRITE_PROJECT_ID=$APPWRITE_PROJECT_ID"
|
|
||||||
echo "APPWRITE_PROJECT_NAME=$APPWRITE_PROJECT_NAME"
|
|
||||||
echo "APPWRITE_PUBLIC_ENDPOINT=$APPWRITE_PUBLIC_ENDPOINT"
|
|
||||||
} >> .env
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Read .env file and convert it to --dart-define arguments
|
|
||||||
ARGS=""
|
|
||||||
while IFS='=' read -r key value || [ -n "$key" ]; do
|
|
||||||
# Ignore empty lines and comments
|
|
||||||
if [[ -n "$key" && ! "$key" =~ ^# ]]; then
|
|
||||||
ARGS+=" --dart-define=${key}=\"${value}\""
|
|
||||||
fi
|
|
||||||
done < .env
|
|
||||||
|
|
||||||
# Build Flutter web
|
|
||||||
eval flutter build web "$ARGS"
|
|
||||||
|
|
||||||
# If --preview flag is provided, run a local preview server
|
|
||||||
if [ "$1" == "--preview" ]; then
|
|
||||||
echo "Starting preview server at http://localhost:3000..."
|
|
||||||
cd build/web || exit 1
|
|
||||||
python3 -m http.server 3000
|
|
||||||
fi
|
|
||||||
5
lib/config/environment.dart
Normal file
5
lib/config/environment.dart
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class Environment {
|
||||||
|
static const String appwriteEndpoint = '[appwriteEndpoint]';
|
||||||
|
static const String appwriteProjectId = '[appwriteProjectId]';
|
||||||
|
static const String appwriteProjectName = '[appwriteProjectName]';
|
||||||
|
}
|
||||||
@ -2,15 +2,16 @@ import 'package:intl/intl.dart';
|
|||||||
import 'package:appwrite/appwrite.dart';
|
import 'package:appwrite/appwrite.dart';
|
||||||
import 'package:appwrite_flutter_starter_kit/data/models/log.dart';
|
import 'package:appwrite_flutter_starter_kit/data/models/log.dart';
|
||||||
import 'package:appwrite_flutter_starter_kit/data/models/project_info.dart';
|
import 'package:appwrite_flutter_starter_kit/data/models/project_info.dart';
|
||||||
|
import 'package:appwrite_flutter_starter_kit/config/environment.dart';
|
||||||
|
|
||||||
/// A repository responsible for handling network interactions with the Appwrite server.
|
/// A repository responsible for handling network interactions with the Appwrite server.
|
||||||
///
|
///
|
||||||
/// It provides a helper method to ping the server.
|
/// It provides a helper method to ping the server.
|
||||||
class AppwriteRepository {
|
class AppwriteRepository {
|
||||||
static const String pingPath = "/ping";
|
static const String pingPath = "/ping";
|
||||||
static const String appwriteProjectId = String.fromEnvironment('APPWRITE_PROJECT_ID');
|
static const String appwriteProjectId = Environment.appwriteProjectId;
|
||||||
static const String appwriteProjectName = String.fromEnvironment('APPWRITE_PROJECT_NAME');
|
static const String appwriteProjectName = Environment.appwriteProjectName;
|
||||||
static const String appwritePublicEndpoint = String.fromEnvironment('APPWRITE_PUBLIC_ENDPOINT');
|
static const String appwritePublicEndpoint = Environment.appwriteEndpoint;
|
||||||
|
|
||||||
final Client _client = Client()
|
final Client _client = Client()
|
||||||
.setProject(appwriteProjectId)
|
.setProject(appwriteProjectId)
|
||||||
|
|||||||
13
prepare-env.sh
Normal file
13
prepare-env.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Script used during deployment on Appwrite Sites
|
||||||
|
|
||||||
|
# Replace [appwriteEndpoint] with APPWRITE_ENDPOINT in environment file
|
||||||
|
sed -i "s|\[appwriteEndpoint\]|$APPWRITE_ENDPOINT|g" lib/config/environment.dart
|
||||||
|
|
||||||
|
# Replace [appwriteProjectId] with APPWRITE_PROJECT_ID in environment file
|
||||||
|
sed -i "s|\[appwriteProjectId\]|$APPWRITE_PROJECT_ID|g" lib/config/environment.dart
|
||||||
|
|
||||||
|
# Replace [appwriteProjectName] with APPWRITE_PROJECT_NAME in environment file
|
||||||
|
sed -i "s|\[appwriteProjectName\]|$APPWRITE_PROJECT_NAME|g" lib/config/environment.dart
|
||||||
Loading…
x
Reference in New Issue
Block a user