shark 1.0.0 shark: ^1.0.0 copied to clipboard
A Flutter server rendering framework for mobile application, server-driven UI, dynamic change your interface in realtime
Shark Flutter 🦈 (Official) #
A Flutter server rendering framework
Project diagram #
How to use #
First, init
Shark library on main method on your application
void main() {
WidgetsFlutterBinding.ensureInitialized();
await Shark.init(hostUrl: 'http://yourhost.com');
runApp(MyApp());
}
Second, set up UI widget
- To be noticed, every thing related to widget is controlled by
SharkController
get
method is where we send the request
late final SharkController _controller;
/// init the shark controller
@override
void initState() {
_controller = SharkController.fromUrl(path: '/container',)..get();
super.initState();
}
@override
Widget build(BuildContext context) {
return SharkWidget(controller: _controller);
}
To redirect to another page, call `redirect`
_controller.redirect('/your_new_path');
If you want to create your own parser
class MyCustomParser extends SharkParser {}
Routing #
shark
auto handles your page routing, if you do not want it, set handleClickEvent
to false
_sharkController = SharkController('/your_path', handleClickEvent: false);
Click Event #
Routing trigger by click event, which you can set it like this on your json widget file.
{
'type': "container",
'click_event': 'route://your_path'
}
The schema route
represents the routing action
Currently, there are only 2 routing action
route
: Navigation to the next page corresponds to the path you define
link
: use url_launcher
internally to open a url on browser, please visit url_launcher to configure the detail requirements for each platform
Caching #
Shark
use dio_cache_interceptor for caching purposes.
When you initialize the shark library, you can pass a cacheStrategy
argument to config your caching setting.
Parsing #
Note that Shark uses dynamic_widget for widget parsing,
To view the json format, go visit documentation on dynamic_widget.
You can also view the express server sample
Future Job #
- Security
- Localization