flutter_simple_treeview 2.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 86

flutter_simple_treeview #

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

Demo #

https://flutter_simple_treeview.codemagic.app

Usage #

                  TreeView(nodes: [
                    TreeNode(content: Text("root1")),
                    TreeNode(
                      content: Text("root2"),
                      children: [
                        TreeNode(content: Text("child21")),
                        TreeNode(content: Text("child22")),
                        TreeNode(
                          content: Text("root23"),
                          children: [
                            TreeNode(content: Text("child231")),
                          ],
                        ),
                      ],
                    ),
                  ]),

2.0.1 #

  • Update links to demo.

2.0.0 #

  • Add controller.

1.0.1 #

  • Add example.

1.0.0 #

  • Publish initial version.

example/lib/main.dart

// Copyright 2020 the Dart project authors.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

import 'package:flutter/material.dart';
import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(Demo());
}

class Demo extends StatefulWidget {
  @override
  _DemoState createState() => _DemoState();
}

class _DemoState extends State<Demo> {
  final Key _key = ValueKey(22);
  final TreeController _controller = TreeController(allNodesExpanded: true);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: Padding(
            padding: EdgeInsets.all(40),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text("FLUTTER-SIMPLE-TREEVIEW"),
                SizedBox(height: 20),
                SizedBox(
                  height: 300,
                  width: 300,
                  child: buildTree(),
                ),
                RaisedButton(
                  child: Text("Expand All"),
                  onPressed: () => setState(() {
                    _controller.expandAll();
                  }),
                ),
                RaisedButton(
                  child: Text("Collapse All"),
                  onPressed: () => setState(() {
                    _controller.collapseAll();
                  }),
                ),
                RaisedButton(
                  child: Text("Expand node 22"),
                  onPressed: () => setState(() {
                    _controller.expandNode(_key);
                  }),
                ),
                RaisedButton(
                  child: Text("Collapse node 22"),
                  onPressed: () => setState(() {
                    _controller.collapseNode(_key);
                  }),
                ),
                FlatButton(
                    child: Text(
                      "Source Code",
                      style: TextStyle(color: Colors.blue),
                    ),
                    onPressed: () async => await launch(
                        'https://github.com/google/flutter.widgets/tree/master/packages/flutter_simple_treeview/example')),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget buildTree() {
    return TreeView(
      treeController: _controller,
      nodes: [
        TreeNode(content: Text("node 1")),
        TreeNode(
          content: Icon(Icons.audiotrack),
          children: [
            TreeNode(content: Text("node 21")),
            TreeNode(
              content: Text("node 22"),
              key: _key,
              children: [
                TreeNode(
                  content: Icon(Icons.sentiment_very_satisfied),
                ),
              ],
            ),
            TreeNode(
              content: Text("node 23"),
            ),
          ],
        ),
      ],
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_simple_treeview: ^2.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_simple_treeview/flutter_simple_treeview.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
72
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_simple_treeview that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test
test any