25-2/1/1
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 8.6 KiB |
57
lib/controller/Widget/home_widget_provider.dart
Normal file
57
lib/controller/Widget/home_widget_provider.dart
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// import 'package:home_widget/home_widget.dart';
|
||||||
|
|
||||||
|
// class TripzHomeWidgetProvider {
|
||||||
|
// static const String widgetName = 'TripzHomeWidget';
|
||||||
|
|
||||||
|
// // Initialize Home Widget
|
||||||
|
// static Future<void> initHomeWidget() async {
|
||||||
|
// await HomeWidget.registerInteractivityCallback(backgroundCallback);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Background Callback for Widget Updates
|
||||||
|
// static Future<void> backgroundCallback(Uri? uri) async {
|
||||||
|
// if (uri?.host == 'updateWidget') {
|
||||||
|
// // Logic to update widget data
|
||||||
|
// await updateWidgetData();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Update Widget Data Method
|
||||||
|
// static Future<void> updateWidgetData() async {
|
||||||
|
// // Fetch current ride details
|
||||||
|
// final rideData = await _fetchCurrentRideDetails();
|
||||||
|
|
||||||
|
// // Update Widget with Ride Information
|
||||||
|
// await HomeWidget.saveWidgetData<String>(
|
||||||
|
// 'ride_destination', rideData.destination);
|
||||||
|
// await HomeWidget.saveWidgetData<String>(
|
||||||
|
// 'ride_estimated_time', rideData.estimatedTime);
|
||||||
|
// await HomeWidget.saveWidgetData<double>('ride_fare', rideData.fare);
|
||||||
|
|
||||||
|
// // Trigger Widget Update
|
||||||
|
// await HomeWidget.updateWidget(
|
||||||
|
// name: widgetName,
|
||||||
|
// iOSName: 'TripzWidgetProvider',
|
||||||
|
// androidName: 'com.mobileapp.store.ride.HomeWidgetProvider',
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Mock method to fetch ride details (replace with actual implementation)
|
||||||
|
// static Future<RideData> _fetchCurrentRideDetails() async {
|
||||||
|
// // Implement actual data fetching logic
|
||||||
|
// return RideData(
|
||||||
|
// destination: 'Downtown Office', estimatedTime: '25 mins', fare: 15.50);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Ride Data Model
|
||||||
|
// class RideData {
|
||||||
|
// final String destination;
|
||||||
|
// final String estimatedTime;
|
||||||
|
// final double fare;
|
||||||
|
|
||||||
|
// RideData(
|
||||||
|
// {required this.destination,
|
||||||
|
// required this.estimatedTime,
|
||||||
|
// required this.fare});
|
||||||
|
// }
|
||||||
18
lib/homw_widget.dart
Normal file
18
lib/homw_widget.dart
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
class WidgetManager {
|
||||||
|
static const platform = MethodChannel('com.mobileapp.store.ride/widget');
|
||||||
|
|
||||||
|
static Future<void> updateWidget() async {
|
||||||
|
try {
|
||||||
|
await platform.invokeMethod('updateWidget');
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
print("Failed to update widget: '${e.message}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Example usage:
|
||||||
|
void updateHomeScreenWidget() {
|
||||||
|
WidgetManager.updateWidget();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user