shark 1.0.1 copy "shark: ^1.0.1" to clipboard
shark: ^1.0.1 copied to clipboard

outdated

A Flutter server rendering framework for mobile application, server-driven UI, dynamic change your interface in realtime

Shark Flutter 🦈 (Official) #

codecov pub package CodeFactor

A Flutter server rendering framework

What it is #

Shark is a server rendering framework, a server-driven UI framework.

Simple use case of shark

Let say you have a text widget, you specify it as json on the server return to the client, the client use shark to receive the text widget and show the UI successfully.

After a while, you want to change the text widget to a button, instead of modify it on the client code and go through all the mobile app store update process, you only need to modify the text widget to a button widget on the server, and the shark client received it, showed the newest UI.

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
56
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A Flutter server rendering framework for mobile application, server-driven UI, dynamic change your interface in realtime

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

device_info_plus, dio, dio_cache_interceptor, dynamic_widget, flutter, path_provider, url_launcher

More

Packages that depend on shark