An open API service indexing awesome lists of open source software.

https://github.com/naimcode/flutter-starter-kit


https://github.com/naimcode/flutter-starter-kit

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

## Table of Contents
- [Table of Contents](#table-of-contents)
- [Architecture](#architecture)
- [Authentication](#authentication)
- [Deep Linking](#deep-linking)
- [Background Tasks](#background-tasks)
- [Offline Downloads](#offline-downloads)
- [Notifications](#notifications)
- [Remote Configuration](#remote-configuration)
- [AI Chat Integration](#ai-chat-integration)
- [Permission Management](#permission-management)
- [Analytics \& Monitoring](#analytics--monitoring)
- [Adaptive Theming](#adaptive-theming)
- [Socket Communication](#socket-communication)
- [In-App Messaging](#in-app-messaging)
- [Getting Started](#getting-started)
- [Dependencies](#dependencies)

## Architecture
This app follows a layered architecture with separation of concerns:
- **Core Layer**: Contains services, repositories and domain logic
- **Presentation Layer**: UI components and screens
- **Infrastructure Layer**: External integrations

## Authentication

The app supports multiple auth methods via Firebase Auth:

```dart
// Sign in with email/password
await AuthProvider().signInWithEmailPassword('email@example.com', 'password');

// Sign in with Google
await AuthProvider().signInWithGoogle();

// Sign out
await AuthProvider().signOut();
```

Access current user:
```dart
final user = AuthProvider().currentUser;
if (user != null) {
// User is signed in
}
```

## Deep Linking

The app handles deep links and universal links for seamless navigation:

```dart
// All setup is managed by DeepLinkHandler

// To navigate to a specific route from a link:
_appRouter.router.push('/path/to/route');

// Testing deep links:
// iOS: xcrun simctl openurl booted "yourapp://path/to/route"
// Android: adb shell am start -a android.intent.action.VIEW -d "yourapp://path/to/route"
```

## Background Tasks

For operations that need to run in the background:

```dart
// Queue a background task
await BackgroundTaskQueue().enqueue(
BackgroundTask(
type: 'form_upload',
payload: {
'formId': 'user-submission-123',
'images': ['/path/to/image1.jpg', '/path/to/image2.jpg'],
},
priority: TaskPriority.high,
),
);

// Register task handler
BackgroundTaskQueue().registerTaskHandler('form_upload', FormUploadHandler());
```

## Offline Downloads

Download and manage files for offline use:

```dart
// Initialize download manager
await DownloadManager().initialize();

// Start a download
final task = await DownloadManager().downloadFile(
url: 'https://example.com/music.mp3',
fileName: 'awesome_song.mp3',
title: 'Awesome Song',
artist: 'Great Artist',
albumArt: 'https://example.com/album_cover.jpg',
);

// Pause download
await DownloadManager().pauseDownload(task.id);

// Resume download
await DownloadManager().resumeDownload(task.id);

// Delete download
await DownloadManager().deleteDownload(task.id);

// Play downloaded file
await MusicPlayerService().playDownloadedTrack(task.id);

// Get all downloads
final allDownloads = DownloadManager().getAllDownloads();
```

Navigate to downloads screen:
```dart
Navigator.pushNamed(context, 'downloads');
```

Add download button to your UI:
```dart
DownloadButton(
url: 'https://example.com/music.mp3',
fileName: 'awesome_song.mp3',
title: 'Awesome Song',
artist: 'Great Artist',
albumArt: 'https://example.com/album_cover.jpg',
),
```

## Notifications

Handle push notifications with Firebase Messaging:

```dart
// Initialize notification service
await NotificationService().initialize(
onMessageOpenedApp: (message) {
// Handle notification tap when app in background
if (message.data.containsKey('route')) {
_appRouter.router.pushNamed(message.data['route']);
}
},
);

// Show local notification
await NotificationService().showNotification(
title: 'Task Complete',
body: 'Your background task has finished',
payload: {'route': 'task-details/123'},
);
```

## Remote Configuration

Manage app features and settings remotely:

```dart
// Initialize remote config
await RemoteConfigService().initialize();

// Get string value
String apiKey = RemoteConfigService().getString('api_key');

// Get bool value
bool isBetaEnabled = RemoteConfigService().isFeatureEnabled('beta_features');

// Get numeric value
double refreshInterval = RemoteConfigService().getDouble('refresh_interval');
```

## AI Chat Integration

Integrate AI conversations into your app:

```dart
// Initialize AI service
await AIService().initialize(
openAIKey: 'your_openai_api_key',
defaultModel: 'gpt-3.5-turbo',
);

// Send message to AI
final response = await AIService().sendMessage(
'Hello, what can you do?',
model: 'gpt-3.5-turbo',
);

// Get response content
print(response.content);

// Navigate to chat screen
Navigator.pushNamed(context, 'ai-chat');
```

## Permission Management

Handle runtime permissions elegantly:

```dart
// Request permission
final isGranted = await PermissionsService().requestPermission(
Permission.camera,
rationaleMessage: 'We need camera access to scan QR codes',
);

// Check permission status
final status = await PermissionsService().checkPermission(Permission.camera);

// Request multiple permissions
final results = await PermissionsService().requestPermissions(
[Permission.camera, Permission.location],
);
```

## Analytics & Monitoring

Track user behavior and app performance:

```dart
// Log event
AnalyticsService().logEvent(
name: 'button_clicked',
parameters: {'button_id': 'login_button'},
);

// Log screen view
AnalyticsService().logScreenView('HomeScreen');

// Track error
AnalyticsService().logError('Failed to load data', StackTrace.current);

// Start performance trace
final trace = PerformanceService().startTrace('data_loading');
// ... perform operation
trace.stop();
```

## Adaptive Theming

The app supports light and dark themes with dynamic customization:

```dart
// Theme is applied based on app config or system preference in main.dart
ThemeMode themeMode = AppTheme().getThemeMode();

// Force theme mode
// In settings screen
ThemeProvider().setThemeMode(ThemeMode.dark);

// Clear theme cache when remote config changes
AppTheme().clearCache();
```

## Socket Communication

Real-time communication with WebSockets:

```dart
// Connect to socket
await SocketService().connect('wss://example.com/socket');

// Listen to events
SocketService().on('new_message', (data) {
// Handle incoming message
});

// Send message
SocketService().emit('send_message', {
'text': 'Hello!',
'timestamp': DateTime.now().toIso8601String(),
});

// Disconnect
SocketService().disconnect();
```

## In-App Messaging

Display banners, modals and announcements:

```dart
// Show banner message
BannerManager().showBanner(
title: 'New Feature Available',
message: 'Try our new chat experience!',
action: BannerAction(
label: 'Try it',
onPressed: () => Navigator.pushNamed(context, 'ai-chat'),
),
duration: const Duration(seconds: 5),
);

// Show modal
BannerManager().showModal(
title: 'Subscription Required',
message: 'Get access to premium features',
primaryAction: BannerAction(
label: 'Subscribe',
onPressed: () => Navigator.pushNamed(context, 'subscription'),
),
secondaryAction: BannerAction(
label: 'Not Now',
onPressed: () => Navigator.pop(context),
),
);

// Check for announcements from Remote Config
InAppMessagingService().showAnnouncementIfAvailable(context);
```

## Getting Started

1. Clone the repository
2. Run `flutter pub get` to install dependencies
3. Set up your Firebase project and add google-services.json/GoogleService-Info.plist
4. Configure your API keys in a secure way
5. Run the app with `flutter run`

## Dependencies

See the pubspec.yaml file for a complete list of dependencies.
# flutter-starter-kit