Get Widgets
The getWidgets() function is used to fetch widgets based on specified parameters.
Steps to Get Widgets
Build a
GetWidgetRequestobject using theGetWidgetRequestBuilderclass.Call the
getWidgets()function using the instance of theLMFeedClientclass.Use the response as per your requirement.
// Specify the parameters for fetching widgets
int page = 1;
int pageSize = 10;
String searchKey = "category";
String searchValue = "news";
// Build the request object
GetWidgetRequest request = (GetWidgetRequestBuilder()
..page(page)
..pageSize(pageSize)
..searchKey(searchKey)
..searchValue(searchValue))
.build();
// Get the response from calling the function
final GetWidgetResponse response = await lmFeedClient.getWidgets(request);
// Process the response, as per requirement
if(response.success){
// your function to handle successful retrieval of widgets
handleWidgets(response.widgets);
}else{
// your function to handle error message
handleWidgetsError(response.errorMessage);
}
tip
Fetching widgets allows you to display dynamic content in your application, enhancing user engagement. Custom widgets allow you fetch custom data from the backend to render any custom views.
Models
GetWidgetRequest
List of parameters for the GetWidgetRequest class
| Variable | Type | Description | Optional | 
|---|---|---|---|
| page | int | Page number for pagination | ✔ | 
| pageSize | int | Number of items per page | ✔ | 
| searchKey | String | Key for filtering widgets | ✔ | 
| searchValue | String | Value for filtering widgets | ✔ | 
GetWidgetResponse
List of parameters for the GetWidgetResponse class
| Variable | Type | Description | Optional | 
|---|---|---|---|
| success | bool | API success status | |
| errorMessage | String | Error message in case of failure | ✔ | 
| widgets | List<WidgetModel> | List of widget models | ✔ |