Service Finder Flutter Project

Service Finder — Flutter Implementation Plan

Service Finder — Flutter Implementation Plan

A developer-ready, copy-paste friendly Blogger post with phases, architecture, feature checklist, and Flutter + API integration snippets for the Service Finder app (Consumers, Workers, Admins, Secretary).

1. Project Overview

Mobile app to search and hire local service workers (electricians, plumbers, carpenters). Roles: Admin, Secretary, Worker, Consumer. Backed by a REST API (users, worker_service, requests, payments, reviews, notifications).

Tech stack

  • Flutter (Android + iOS)
  • Backend: REST API (Node/Express, Laravel, Django, etc.)
  • Database: MySQL / PostgreSQL
  • Auth: JWT
  • State: Riverpod or BLoC
  • Networking: dio
  • Push: Firebase Cloud Messaging

2. Architecture & Folder Structure

// lib/
main.dart
core/
  constants/
  utils/
  network/
models/
services/    // API clients (dio)
providers/   // riverpod/bloc
views/
  auth/
  consumer/
  worker/
  admin/
widgets/
routes/
assets/

3. Development Phases (High level)

  1. Setup & Core: project, themes, base API client, environment config.
  2. Auth: Register, Login, role-based routing, token storage.
  3. Consumer flow: search, view worker, create request, pay, review.
  4. Worker flow: profile, manage services, accept jobs, earnings.
  5. Admin/Secretary: manage users, categories, dashboard.
  6. Notifications & Real-time: FCM + in-app notifications.
  7. Testing & Deployment: unit/widget tests, performance, store release.

4. Feature → API Mapping

FeatureHTTPEndpoint
Register userPOST/users
LoginPOST/auth/login
Search workersGET/users?role_id=worker&location_id=...
Create requestPOST/requests
Update requestPUT/requests/{id}
PaymentsPOST/payments
ReviewsPOST/GET/reviews
NotificationsGET/PUT/notifications

5. Feature-by-feature Implementation Checklist (Developer-ready)

Auth & User

  • Create auth screens: LoginScreen, RegisterScreen. Store JWT in shared_preferences.
  • Implement AuthService wrapping dio with interceptor to attach token.
  • Role-based navigation: after login route user to consumer / worker / admin home.

Consumer Flow

  • Search page with filters (category, city/pincode). Use debounced search and show suggestions.
  • Worker profile page showing services (from worker_service), reviews, contact, call button.
  • Booking form → POST /requests. After success show payment screen.
  • Payment screen: integrate Razorpay / Stripe SDK, then call POST /payments on success.
  • View bookings (GET /requests?consumer_id=...), cancel or reschedule (PUT).

Worker Flow

  • Profile editor: edit skills, add categories and rates (PUT /users/{id}).
  • Jobs list: GET /requests?worker_id=.... Accept/Reject via PUT request status.
  • Earnings & payouts: GET payments for worker (GET /payments?worker_id=...).

Admin & Secretary

  • User management pages: list users (GET /users), approve workers.
  • Category & service management: CRUD endpoints for service_category.
  • Dashboard: simple stats (counts of requests, earnings, top workers).

Notifications

  • Setup Firebase Cloud Messaging; when backend sends push, show local notification and add to GET /notifications.
  • Tappable notifications should deep-link to booking or profile.

Polish & Production

  • Add form validation, loading states, skeletons, and retry logic for network errors.
  • Write unit tests for models/services and widget tests for critical screens.
  • Implement analytics (optional) and crash reporting (Firebase Crashlytics).

6. Flutter → API Code Snippets (copy-paste friendly)

6.1 Dio API client (base)

// lib/core/network/api_client.dart
import 'package:dio/dio.dart';

class ApiClient {
  late Dio dio;
  ApiClient(String baseUrl, String? token){
    dio = Dio(BaseOptions(baseUrl: baseUrl, connectTimeout: 5000, receiveTimeout: 5000));
    if(token != null){
      dio.options.headers['Authorization'] = 'Bearer $token';
    }
    // Add interceptors: logging, refresh token handling
  }
}

6.2 AuthService (register/login)

// lib/services/auth_service.dart
import 'package:dio/dio.dart';

class AuthService {
  final Dio _dio;
  AuthService(this._dio);

  Future> login(String email, String password) async{
    final r = await _dio.post('/auth/login', data: {'email': email, 'password': password});
    return r.data; // { token, user }
  }

  Future> register(Map body) async{
    final r = await _dio.post('/users', data: body);
    return r.data;
  }
}

6.3 Example: Create Request (consumer)

// lib/services/request_service.dart
class RequestService {
  final Dio _dio;
  RequestService(this._dio);

  Future> createRequest(Map body) async{
    final r = await _dio.post('/requests', data: body);
    return r.data; // { request_id, message }
  }
}

6.4 Example: Payment call after gateway success

// after payment is successful from gateway
final paymentResp = await dio.post('/payments', data: {
  'request_id': requestId,
  'consumer_id': consumerId,
  'worker_id': workerId,
  'amount': amount,
  'payment_method': 'razorpay'
});

6.5 Model example (User)

// lib/models/user.dart
class User {
  final int userId;
  final String fullName;
  final int roleId;

  User({required this.userId, required this.fullName, required this.roleId});

  factory User.fromJson(Map json) => User(
    userId: json['user_id'],
    fullName: json['full_name'],
    roleId: json['role_id'],
  );
}

7. Testing & QA

  • Unit tests for services and models (flutter_test).
  • Widget tests for screens: auth flow, search, booking screen.
  • End-to-end tests with integration_test or third-party tools.

8. Deployment Checklist

  • Prepare app icons and store listing assets.
  • Setup CI: build, run tests, build APK / IPA.
  • Backend: enable HTTPS, secure DB and backups, configure payment webhooks.
  • Monitor: Crashlytics, performance monitoring, logging.

Post a Comment

0 Comments

Me