cr_json_widget 1.1.1 copy "cr_json_widget: ^1.1.1" to clipboard
cr_json_widget: ^1.1.1 copied to clipboard

A widget, that visualises a tree structure, where a node can be any widget.

example/lib/main.dart

import 'package:cr_json_wiget_example/pages/cr_json_page.dart';
import 'package:cr_json_wiget_example/pages/cr_json_recycler_page.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MainPage(),
    );
  }
}

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

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  static const _tabs = [
    Tab(
      text: 'CrJsonWidget',
      icon: Icon(Icons.create),
    ),
    Tab(
      text: 'CrJsonRecyclers',
      icon: Icon(Icons.construction),
    ),
  ];

  static const _pages = [
    CrJsonPage(),
    CrJsonRecyclerPage(),
  ];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: _tabs.length,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('CRJsonWidgets Example'),
          bottom: const TabBar(tabs: _tabs),
          actions: [
            IconButton(
              onPressed: ExpandNodesController.instance.expandAllNodes,
              icon: const Icon(Icons.expand),
            ),
          ],
        ),
        body: const TabBarView(
          children: _pages,
        ),
      ),
    );
  }
}

class ExpandNodesController extends ChangeNotifier {
  ExpandNodesController._();

  static final instance = ExpandNodesController._();

  bool isExpanded = false;

  void expandAllNodes() {
    isExpanded = !isExpanded;
    notifyListeners();
  }
}
21
likes
160
pub points
71%
popularity

Publisher

verified publishercleveroad.com

A widget, that visualises a tree structure, where a node can be any widget.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on cr_json_widget