Flutter UI #35: Fun with the Tree View in Flutter


Flutter UI #35: Fun with the Tree View in Flutter

Tutorial and code of Tree View in Flutter. Copy and paste the below code as per your requirements.

flutter_tree: ^1.1.0

import 'package:flutter/material.dart';
import 'package:flutter_tree/flutter_tree.dart';


void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Tree',
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(title: const Center(child: Text('Flutter Tree'))),
         body: const TreeNode(
           title: Text('This is content!'),
           children: [
             TreeNode(
               title: Text('This is content!'),
               children: <Widget>[
                 TreeNode(title: Text('This is content!')),
                  TreeNode(
                   title: Text('This is title!'),
                   children: <Widget>[
                     TreeNode(title: Text('This is content!')),
                     TreeNode(title: Text('This is content!')),
                     TreeNode(title: Text('This is content!')),
                   ],
                 ),
                 TreeNode(title: Text('This is content!')),
                 TreeNode(title: Text('This is content!')),
                 TreeNode(
                   title: Text('This is content!'),
                   children: <Widget>[
                     TreeNode(title: Text('This is content!')),
                     TreeNode(title: Text('This is content!')),
                     TreeNode(title: Text('This is content!')),
                   ],
                 ),
               ],
             ),
           ],
         ),
      ),
    );
  }
}

Leave a Reply

Your email address will not be published.