gosemolis_utility

Last updated:

0 purchases

gosemolis_utility Image
gosemolis_utility Images
Add to Cart

Description:

gosemolis utility

Flutter Version #
This project using Flutter version 3.7.2
Design Arhitecture #
We are using DDD for several logics

LocationCubit #
located at lib/core/modules/location/bloc/location/location_cubit.dart
which is a state management class. It is responsible for handling various location-related functionalities in a Flutter app. functionalities:


Location Tracking and Permissions:

The class manages location tracking by using the Geolocator package to obtain the user's current location and provide permissions handling for location access.
It uses Geolocator to request and hndle location permissions and checks if the location service is enabled.
It also listens to location service status changes and updates the state accordingly



Map Functionality:

The class deals with map-related functionalities using both Google Maps and OpenStreetMap (OSM).
It sets up map styles using provided assets or buffer strings.
It handles markers for user location, destination, and other points on the map.



Background Task Handling:

The class handles background tasks for location tracking using the FlutterForegroundTask package.
It starts and stops a foreground service for location tracking even when the app is in the background.
It listens to background task events using a ReceivePort to receive location updates and updates the app's state accordingly.



Address Geocoding:

The class provides geocoding functionality to convert latitude and longitude coordinates into human-readable addresses using the geocoding package and a custom OSM API implementation.



Miscellaneous:

The class manages different states for user location, destination, saved location, driver marker, etc., using a custom LocationState class.
It also handles the app's current order background state and updates the state accordingly.



Overall, the LocationCubit class serves as a central location manager in a Flutter app, handling location tracking, map interactions, geocoding, and background task handling efficiently to provide a smooth user experience for location-based functionalities.
Tracking User with API and Centrifugo Subscription #
This documentation explains how the provided code is used to track users in a Flutter app using API calls and Centrifugo subscriptions. The code includes the usage of Dio for API calls, flutter_foreground_task for running tasks in the background, and centrifuge for handling real-time data subscriptions.
Prerequisites #
dependencies:
centrifuge # Replace with the correct version
dio # Replace with the correct version
flutter_foreground_task # Replace with the correct version
geolocator # Replace with the correct version
# Other dependencies...
copied to clipboard
Run flutter pub get to install the packages.
How the Code Works #
The provided code is part of the implementation of tracking user location and sending periodic updates using a combination of API calls and Centrifugo subscriptions. Below is an explanation of key components:
1. TrackingWrapper class #
This class handles the tracking and subscription logic based on the selected environment (GoSemolisEnv). It initializes the tracking and subscription handlers based on the provided environment.
2. TraccarLocationImpl class #
This class implements the TaskHandler interface provided by the flutter_foreground_task package. It is responsible for handling periodic tasks in the background. The class receives a TrackingWrapper instance during initialization.
3. Tracking with API (_onTrackingLocation method) #
This method handles the tracking logic when the user's location needs to be sent to the server via API calls. The method checks if tracking is active, and if so, it initializes a stream of user location updates using the geolocator package.
4. Centrifugo Subscription (_onRetrieveLocation method) #
This method handles the subscription logic when the app needs to receive real-time location updates from the server via Centrifugo. It connects to the Centrifugo server and subscribes to a specific channel to receive location updates.
5. Sending Location Updates (_sendLocationToServer method) #
This method is responsible for sending the user's location to the server either via API calls or Centrifugo, based on the tracking mode.
6. Initializing Centrifugo Client (_initCentrifugoClient method) #
This method initializes the Centrifugo client to handle real-time subscriptions for receiving location updates.
7. Background Task Handling #
The class implements the TaskHandler interface, allowing it to handle repeated events in the background. The onRepeatEvent method is called periodically by the flutter_foreground_task package, and it triggers the tracking and subscription logic.
How to Use the Code #
To use the provided code for tracking users in your Flutter app, follow these steps:


Ensure you have installed the required packages in your pubspec.yaml file.


Create an instance of the TrackingWrapper class and pass the desired environment (GoSemolisEnv) to it. You can use this instance to initialize the TraccarLocationImpl class.


Initialize the TraccarLocationImpl class with the TrackingWrapper instance. This class will handle background tasks and tracking logic.


Configure the required settings for Centrifugo and Traccar, such as the server URLs and ports.


Call the startCallback, startCallbackDev, or startCallbackStaging methods based on the desired environment in the main function to start tracking and subscription logic when the app is launched.


Run the app, and it will start tracking users and handling real-time location updates using the specified methods.


Please note that this documentation provides an overview of the provided code's functionality. For a complete integration into your app, additional implementation details and configurations specific to your project may be required.
Flutter Project Folder Structure and Theme Usage Guide #
This Flutter project follows a structured folder organization to keep the code organized and maintainable. The project contains the following folders:
located at lib\core\components
components #
This folder contains small widget components that can be reused across the app. These components are designed to follow a consistent theme to ensure a cohesive user interface.
located at lib\core\theme
theme #
The theme folder contains the core theme setup and different theme variations for the app.

theme_core: This folder provides the general theme configuration, including text styles, color palettes, and constant values. It serves as the foundation for the overall app design.
theme_light: The theme_light folder is dedicated to providing the color scheme for the light mode of the app. It ensures a visually pleasing and user-friendly experience when the app is in light mode.
theme_dark: Although currently unused, the theme_dark folder is reserved for providing the color scheme and styles for the dark mode of the app in the future.

By running the flutter run command, you can see all the examples and use cases of these components and themes directly in the main.dart file. The examples provided demonstrate how to use the defined themes and components throughout the app's UI, ensuring a consistent and polished user experience.
The structured organization and well-defined themes in this Flutter project contribute to better code readability, maintainability, and scalability. It allows for easy customization and adaptation of the app's appearance based on different themes and user preferences.
Involved libraries #
State Management Library #
BLoC
freezed
fpdart
Networking Library #
code_id_network
Location #
flutterlocation
FlutterLocation is a custom Flutter plugin that provides an easy-to-use interface to access location services on Android and iOS devices. It allows Flutter developers to retrieve the device's current location (latitude and longitude) and receive location updates in real-time. The plugin simplifies the process of working with location data and enables developers to build location-aware applications with ease.
osm_flutter
OpenStreetMap (OSM) Flutter is a plugin that allows Flutter developers to integrate and display interactive OpenStreetMap maps in their applications. OpenStreetMap is a crowd-sourced mapping platform that provides free and open geographical data. With this plugin, developers can show maps, add markers, draw routes, and implement custom overlays to create feature-rich mapping experiences for their users.
geocoding
Geocoding is a Dart package available on pub.dev that provides geocoding and reverse geocoding functionalities. It allows developers to convert addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), and vice versa. This package is useful for applications that need to work with location data and perform location-based searches.
geolocator
Geolocator is a popular Flutter plugin available on pub.dev that provides easy access to the device's location on both Android and iOS platforms. It allows developers to retrieve the device's current location (latitude and longitude) and provides additional features such as listening for location updates, getting the user's speed and bearing, and checking location service permissions. Geolocator is widely used in location-based applications and services.
infinite_scroll_pagination
The infinite_scroll_pagination package allows you to efficiently implement infinite scroll for lists with large data sources. It provides paginated data loading and scroll listeners for a smooth user experience.
mqtt_client
The mqtt_client package is a Dart library that allows your Flutter app to connect to an MQTT broker and publish/subscribe to topics. It is commonly used for real-time messaging and IoT applications.
flutter_foreground_task
The flutter_foreground_task package allows you to run background tasks in Flutter apps while keeping the app in the foreground. It is useful for tasks that need to be executed periodically or on specific events.
easy_localization
The easy_localization package simplifies the localization process in Flutter apps. It provides a straightforward way to handle translations and internationalization in your app.
another_flushbar
The another_flushbar package allows you to display highly customizable and attractive notifications or alerts in your Flutter app.
location
The location package provides a high-level abstraction for location services in Flutter apps. It makes it easy to get the device's current location and listen for location updates.
dio
The dio package is a powerful HTTP client for Dart that allows you to make network requests and handle responses efficiently.
freezed_annotation
The freezed_annotation package is used in combination with the Freezed package for code generation of unions and data classes in Dart. It simplifies creating immutable data models.
flutter_bloc
The flutter_bloc package provides an implementation of the BLoC (Business Logic Component) design pattern for Flutter apps. It allows for a clear separation of UI and business logic, making it easier to manage app state.
flutter_svg
The flutter_svg package allows you to easily render SVG (Scalable Vector Graphics) files as Flutter widgets. It provides high-quality vector graphics support for your app.
google_maps_flutter
The google_maps_flutter package enables you to embed Google Maps into your Flutter app. It provides features like markers, polylines, and map controls.
geocoding
The geocoding package provides geocoding and reverse geocoding capabilities. It allows you to convert addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739).
fast_immutable_collections
The fast_immutable_collections package provides efficient immutable collections for Dart. It offers List and Set data structures that are optimized for performance and memory efficiency.
fpdart
The fpdart (Functional Programming in Dart) package brings functional programming concepts to Dart. It provides functional data structures, functions, and utilities to make functional programming easier in Dart.
google_maps_webservice0-nullsafety.5
The google_maps_webservice package allows you to access the Google Maps Web Service API. It provides methods for geocoding, reverse geocoding, places, and directions.
flag
The flag package allows you to display country flags in your Flutter app. It provides flag icons for various countries in different styles.
pinput1
The pinput package provides a customizable PIN input widget for Flutter apps. It is useful for implementing PIN-based authentication or verification.
dotted_border+3
The dotted_border package allows you to add a dotted border around a widget in Flutter. It provides options to customize the appearance and style of the dotted border.
rxdart0
The rxdart package provides reactive extensions for Dart. It enables you to work with reactive streams, combining and transforming them in a functional reactive style.
collection0
The collection package provides additional collections and utilities for Dart. It includes the IterableBase class, which allows you to create custom iterable classes easily.
bloc
The bloc package provides an implementation of the BLoC (Business Logic Component) design pattern for Flutter apps. It allows for a clear separation of UI and business logic, making it easier to manage app state.
modal_bottom_sheet-pre
The modal_bottom_sheet package allows you to present modal bottom sheets in Flutter apps. It offers customizable and visually appealing modal sheets.
cached_network_image
The cached_network_image package provides an easy way to load and cache images from the network in Flutter apps. It improves performance by caching images for efficient loading.
firebase_messaging
The firebase_messaging package allows your Flutter app to receive and handle push notifications from Firebase Cloud Messaging (FCM). It is commonly used to implement push notifications in apps.
flutter_osm_plugin
The flutter_osm_plugin package provides an OpenStreetMap (OSM) widget for Flutter apps. It allows you to embed OSM maps with customizable markers, polylines, and overlays.
flutter_polyline_points
The flutter_polyline_points package allows you to find polyline points from one location to another on Google Maps in Flutter. It is useful for drawing routes and polylines on the map.
centrifuge
The centrifuge package is a Dart client for the Centrifugo real-time messaging server. It enables your Flutter app to subscribe to channels and receive real-time updates.
hive
The hive package is a lightweight and fast NoSQL database for Flutter. It allows you to store data locally in a key-value format, making it suitable for caching and simple database needs.
path
The path package provides utilities for working with file and directory paths in Dart. It simplifies path manipulation and ensures platform compatibility.
pointycastle
The pointycastle package is a cryptographic library for Dart. It allows you to perform cryptographic operations such as encryption, decryption, and hashing.
encrypt
The encrypt package provides encryption and decryption utilities for Dart. It allows you to encrypt sensitive data in your Flutter app.
android_path_provider
The android_path_provider package provides additional path provider functionality specifically for Android in Flutter. It extends the path_provider package for Android-specific path handling.
path_provider4
The path_provider package provides utilities for getting common directories (like documents, cache, and temporary) in your Flutter app. It allows you to access the filesystem on both Android and iOS.
image_picker
The image_picker package allows your Flutter app to select images from the gallery or take photos using the device's camera. It provides a platform-independent API for image picking.
pdf_compressor
The pdf_compressor package provides functionality to compress PDF files in Flutter apps. It is useful for reducing the size of PDF documents before sharing or uploading.
flutter_image_compress
The flutter_image_compress package allows you to compress images in Flutter apps. It is useful for reducing image file sizes without compromising quality.
file_picker
The file_picker package allows users to select files from the device's filesystem in Flutter apps. It supports file picking from different sources like the gallery and the file system.
permission_handler0
The permission_handler package simplifies handling permissions in Flutter apps. It allows you to request and check permissions for various features like camera, location, and storage.
expandable
The expandable package provides widgets for creating expandable views in Flutter apps. It allows you to create collapsible and expandable sections within your UI.
slide_action
The slide_action package provides a widget for creating slide actions in Flutter apps. It allows you to add sliding actions to list items or cards for a smoother user experience.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.