serve_dynamic_ui 0.0.2 copy "serve_dynamic_ui: ^0.0.2" to clipboard
serve_dynamic_ui: ^0.0.2 copied to clipboard

A Flutter plugin to render dynamic widgets based on server driven ui.

example/lib/main.dart

import 'package:example/custom_actions/snackbar_action_handler.dart';
import 'package:example/listeners_impl/widget_scroll_listener.dart';
import 'package:example/custom_widgets/dy_widget_card.dart';
import 'package:flutter/material.dart';
import 'package:serve_dynamic_ui/serve_dynamic_ui.dart';
import 'listeners_impl/text_update_listener.dart';

void main() {
  Map<String, DynamicWidgetHandler> widgetHandlerMap = {
    "dy_widget_card": (json) => DynamicWidgetCard.fromJson(json)
  };

  Map<RegExp, ActionHandler> actionHandlerMap = {
    RegExp(r'(^/?showSnackbar/?$)'): SnackBarActionHandler()
  };

  ServeDynamicUI.init(
    widgetHandlers: widgetHandlerMap,
    actionHandlers: actionHandlerMap,
  );
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MyHomePage(title: 'Flutter Demo Home Page');
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    DynamicListeners.addListener(WidgetScrollListener());
    DynamicListeners.addListener(TextUpdateListener());
  }

  @override
  Widget build(BuildContext context) {
    return ServeDynamicUIMaterialApp(
      home: (context) {
        return ServeDynamicUI.fromAssets('assets/json/sample.json');
      },
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
        useMaterial3: false,
      ),
      debugShowCheckedModeBanner: false,
    );
  }
}
19
likes
140
points
139
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to render dynamic widgets based on server driven ui.

Repository (GitHub)
View/report issues

Topics

#dynamic-widgets #server-driven-ui #backend-driven-ui

Documentation

API reference

License

MIT (license)

Dependencies

dio, flutter, json_annotation, scroll_to_index, simple_html_css

More

Packages that depend on serve_dynamic_ui