Skip to main content

Get Widgets

The getWidgets() function is used to fetch widgets based on specified parameters.

Steps to Get Widgets

  1. Build a GetWidgetRequest object using the GetWidgetRequestBuilder class.

  2. Call the getWidgets() function using the instance of the LMFeedClient class.

  3. 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

VariableTypeDescriptionOptional
pageintPage number for pagination
pageSizeintNumber of items per page
searchKeyStringKey for filtering widgets
searchValueStringValue for filtering widgets

GetWidgetResponse

List of parameters for the GetWidgetResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageStringError message in case of failure
widgetsList<WidgetModel>List of widget models