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

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

example/lib/main.dart

import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:shark/shark.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  await Shark.init(hostUrl: 'http://localhost:8080');

  runApp(
    EasyLocalization(
      supportedLocales: [Locale('en'), Locale('zh')],
      path: 'assets/translations',
      child: MyMaterialApp(),
    ),
  );
}

class MyMaterialApp extends StatelessWidget {
  const MyMaterialApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
      locale: context.locale,
      home: MyApp(),
    );
  }
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late final SharkController _controller;

  @override
  void initState() {
    _controller = SharkController.fromUrl(
      context,
      '/first_page',
    )..get();

    _controller.addParse(TranslatedTextParser());

    _controller.stateStream.listen((state) {
      if (state is SharkWidgetState) {
        print(_controller.value);
      }
    });

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SharkWidget(
        controller: _controller,
        clickEvent: (event) {
          print(event);
        },
      ),
    );
  }
}
57
likes
130
points
102
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

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

More

Packages that depend on shark