Skip to content

Commit f37b8dc

Browse files
committed
fix: convert docs.json to docs.page format and populate index.mdx
- Fixed docs.json from Mintlify format to simple docs.page format - Populated index.mdx with comprehensive content as main landing page - Added missing database-maintenance use case page - Simplified navigation structure for docs.page compatibility - Should resolve empty docs.page issue
1 parent ffe13e6 commit f37b8dc

File tree

3 files changed

+167
-107
lines changed

3 files changed

+167
-107
lines changed

docs.json

Lines changed: 1 addition & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,4 @@
11
{
22
"name": "Flutter Workmanager",
3-
"$schema": "https://mintlify.com/schema.json",
4-
"logo": {
5-
"dark": "/logo/dark.svg",
6-
"light": "/logo/light.svg"
7-
},
8-
"favicon": "/favicon.svg",
9-
"colors": {
10-
"primary": "#0D9373",
11-
"light": "#07C983",
12-
"dark": "#0D9373",
13-
"anchors": {
14-
"from": "#0D9373",
15-
"to": "#07C983"
16-
}
17-
},
18-
"topbarLinks": [
19-
{
20-
"name": "Support",
21-
"url": "https://github.com/fluttercommunity/flutter_workmanager/issues"
22-
}
23-
],
24-
"topbarCtaButton": {
25-
"name": "GitHub",
26-
"url": "https://github.com/fluttercommunity/flutter_workmanager"
27-
},
28-
"tabs": [
29-
{
30-
"name": "API Reference",
31-
"url": "api-reference"
32-
}
33-
],
34-
"anchors": [
35-
{
36-
"name": "Documentation",
37-
"icon": "book-open-cover",
38-
"url": "https://pub.dev/documentation/workmanager/latest/"
39-
},
40-
{
41-
"name": "Community",
42-
"icon": "github",
43-
"url": "https://github.com/fluttercommunity/flutter_workmanager"
44-
}
45-
],
46-
"navigation": [
47-
{
48-
"group": "Get Started",
49-
"pages": [
50-
"introduction",
51-
"installation",
52-
"quickstart"
53-
]
54-
},
55-
{
56-
"group": "Use Cases",
57-
"pages": [
58-
"usecases/data-sync",
59-
"usecases/periodic-cleanup",
60-
"usecases/upload-files",
61-
"usecases/fetch-notifications",
62-
"usecases/database-maintenance"
63-
]
64-
},
65-
{
66-
"group": "Task Management",
67-
"pages": [
68-
"tasks/scheduling",
69-
"tasks/constraints",
70-
"tasks/cancellation"
71-
]
72-
},
73-
{
74-
"group": "Platform Setup",
75-
"pages": [
76-
"setup/android",
77-
"setup/ios"
78-
]
79-
},
80-
{
81-
"group": "Debugging & Testing",
82-
"pages": [
83-
"debugging/overview",
84-
"debugging/notifications",
85-
"debugging/troubleshooting"
86-
]
87-
},
88-
{
89-
"group": "Advanced",
90-
"pages": [
91-
"advanced/architecture",
92-
"advanced/migration",
93-
"advanced/publishing"
94-
]
95-
},
96-
{
97-
"group": "API Reference",
98-
"pages": [
99-
"api-reference/workmanager",
100-
"api-reference/workmanager-android",
101-
"api-reference/workmanager-apple",
102-
"api-reference/platform-interface"
103-
]
104-
}
105-
],
106-
"footerSocials": {
107-
"github": "https://github.com/fluttercommunity/flutter_workmanager",
108-
"discord": "https://discord.gg/rflutterdev"
109-
}
3+
"description": "Background task execution for Flutter apps"
1104
}

docs/index.mdx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,96 @@
1+
---
2+
title: Flutter Workmanager
3+
description: Background task execution for Flutter apps
4+
---
5+
16
# Flutter Workmanager
7+
8+
[![pub package](https://img.shields.io/pub/v/workmanager.svg)](https://pub.dartlang.org/packages/workmanager)
9+
[![pub points](https://img.shields.io/pub/points/workmanager)](https://pub.dev/packages/workmanager/score)
10+
[![likes](https://img.shields.io/pub/likes/workmanager)](https://pub.dev/packages/workmanager/score)
11+
[![popularity](https://img.shields.io/pub/popularity/workmanager)](https://pub.dev/packages/workmanager/score)
12+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/fluttercommunity/flutter_workmanager/test.yml?branch=main&label=tests)](https://github.com/fluttercommunity/flutter_workmanager/actions)
13+
[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fluttercommunity/flutter_workmanager/blob/main/LICENSE)
14+
15+
Execute Dart code in the background, even when your app is closed. Perfect for data sync, file uploads, and periodic maintenance tasks.
16+
17+
## Quick Start
18+
19+
### 1. Install
20+
```yaml
21+
dependencies:
22+
workmanager: ^0.8.0
23+
```
24+
25+
### 2. Platform Setup
26+
- **Android**: Works automatically ✅
27+
- **iOS**: [5-minute setup required](setup/ios)
28+
29+
### 3. Initialize & Use
30+
```dart
31+
@pragma('vm:entry-point')
32+
void callbackDispatcher() {
33+
Workmanager().executeTask((task, inputData) {
34+
print("Background task: $task");
35+
// Your background logic here
36+
return Future.value(true);
37+
});
38+
}
39+
40+
void main() {
41+
Workmanager().initialize(callbackDispatcher);
42+
43+
// Schedule a task
44+
Workmanager().registerPeriodicTask(
45+
"sync-task",
46+
"data-sync",
47+
frequency: Duration(hours: 1),
48+
);
49+
50+
runApp(MyApp());
51+
}
52+
```
53+
54+
## Common Use Cases
55+
56+
| Use Case | Documentation |
57+
|----------|---------------|
58+
| **Sync data from API** | [Data Sync Guide](usecases/data-sync) |
59+
| **Upload files in background** | [File Upload Guide](usecases/upload-files) |
60+
| **Clean up old data** | [Cleanup Guide](usecases/periodic-cleanup) |
61+
| **Fetch notifications** | [Notifications Guide](usecases/fetch-notifications) |
62+
63+
## Architecture
64+
65+
This plugin uses a **federated architecture**:
66+
- `workmanager` - Main package
67+
- `workmanager_android` - Android implementation
68+
- `workmanager_apple` - iOS/macOS implementation
69+
- `workmanager_platform_interface` - Shared interface
70+
71+
All packages are automatically included when you add `workmanager` to pubspec.yaml.
72+
73+
## Key Features
74+
75+
- **Background Task Execution**: Execute Dart code in the background on both Android and iOS platforms
76+
- **Multiple Task Types**: Support for one-off tasks, periodic tasks, and iOS processing tasks
77+
- **Platform Constraints**: Configure network, battery, charging, and other constraints for task execution
78+
- **Debug Support**: Built-in debugging with notifications to track background task execution
79+
80+
## Supported Platforms
81+
82+
| Platform | Support | Notes |
83+
|----------|---------|--------|
84+
| Android | ✅ Full | All WorkManager features supported |
85+
| iOS | ✅ Full | Background Fetch + BGTaskScheduler APIs |
86+
| macOS | 🚧 Planned | Future support through NSBackgroundActivityScheduler |
87+
| Web | ❌ Not supported | Background execution not available |
88+
| Windows/Linux | ❌ Not supported | No background task APIs |
89+
90+
## Navigation
91+
92+
- **[Installation](installation)** - Install and configure the plugin
93+
- **[Quick Start](quickstart)** - Get up and running quickly
94+
- **[Platform Setup](setup/android)** - Configure Android and iOS
95+
- **[Use Cases](usecases/data-sync)** - Real-world implementation examples
96+
- **[Example App](https://github.com/fluttercommunity/flutter_workmanager/tree/main/example)** - Complete working demo
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: "Database Maintenance"
3+
description: "Perform database cleanup, optimization, and maintenance tasks in the background"
4+
---
5+
6+
# Database Maintenance
7+
8+
Automatically maintain your app's local database by cleaning up old records, optimizing indexes, and performing routine maintenance tasks in the background.
9+
10+
## When to Use This
11+
12+
- Remove old/expired database records
13+
- Optimize database indexes and vacuum SQLite
14+
- Archive old data to reduce database size
15+
- Clean up orphaned records and relationships
16+
- Compress and defragment database files
17+
18+
## Quick Implementation
19+
20+
```dart
21+
@pragma('vm:entry-point')
22+
void callbackDispatcher() {
23+
Workmanager().executeTask((task, inputData) async {
24+
if (task == "db_maintenance") {
25+
return await performDatabaseMaintenance();
26+
}
27+
return Future.value(false);
28+
});
29+
}
30+
31+
Future<bool> performDatabaseMaintenance() async {
32+
try {
33+
final db = await DatabaseHelper.getDatabase();
34+
35+
// Remove old records (older than 30 days)
36+
await db.delete(
37+
'logs',
38+
where: 'created_at < ?',
39+
whereArgs: [DateTime.now().subtract(Duration(days: 30)).millisecondsSinceEpoch],
40+
);
41+
42+
// Vacuum database to reclaim space
43+
await db.execute('VACUUM');
44+
45+
// Update statistics
46+
await db.execute('ANALYZE');
47+
48+
return true;
49+
} catch (e) {
50+
print('Database maintenance failed: $e');
51+
return false;
52+
}
53+
}
54+
55+
void scheduleDatabaseMaintenance() {
56+
Workmanager().registerPeriodicTask(
57+
"db_maintenance",
58+
"db_maintenance",
59+
frequency: Duration(days: 7), // Weekly maintenance
60+
constraints: Constraints(
61+
requiresDeviceIdle: true,
62+
requiresBatteryNotLow: true,
63+
),
64+
);
65+
}
66+
```
67+
68+
## Platform Considerations
69+
70+
**Android**: Can perform comprehensive maintenance operations
71+
**iOS**: Limited to 30 seconds - focus on quick cleanup operations

0 commit comments

Comments
 (0)