A widget that displays Beagle’s contents. This is the entry point to load server-driven screens and server-driven UI components to your Flutter application. The BeagleWidget
is a StatefulWidget
that renders widgets through a local JSON or an HTTP request.
See how the structure is represented:
Attribute | Type | Required | Definition |
---|---|---|---|
key | Key | Identifier for Widgets, Elements and SemanticsNodes. | |
screenRequest | BeagleScreenRequest | Provides the url, method, headers and body to the request. | |
screenJson | String | Represents a local screen to be shown. | |
onCreateView | OnCreateViewListener | Function that returns the current BeagleView. |
It’s a class used to make requests in Beagle Flutter. It implements the BeagleNetworkOptions
which brings the method
, headers
and strategy
attributes. Also, the BeagleScreenRequest
class has the url
and body
properties. See the structure below:
Attribute | Type | Required | Definition |
---|---|---|---|
url | String | ✓ | Represents the request relative server URL. |
body | String | Content that will be deliver with the request. | |
headers | Map<String, String> | Headers to be used in the request. | |
method | BeagleHttpMethod | Http method to indicate the desired action to be performed for a given resource. This could be put , get , post , delete , patch and head . | |
strategy | BeagleNetworkStrategy | Cache strategy applied to the request. This could be beagleCacheOnly , beagleWithFallbackToCache , networkWithFallbackToCache , cacheWithFallbackToNetwork , cacheOnly , networkOnly and cacheFirst . |
A function that follows the struct void Function(BeagleView view)
and provides the current BeagleView
when it’s available.
You can use it wherever you want to show server-driven content.
BeagleWidget
there informing at least a local JSON or a BeagleScreenRequest
with the url
of your BFF.In the example below, you will see it in the Scaffold
widget body:
Scaffold(
appBar: AppBar(
title: const Text('Beagle Sample'),
),
body: BeagleWidget(
screenRequest: BeagleScreenRequest('components'),
),
);
BeagleSdk.init
passing at least the baseUrl
property before using the BeagleWidget
.Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.