Open Marrawi1994 opened 2 years ago
Hi Guys ... For anyone need to use this library with null safety support .. follow these steps :
First : copy files from root directory -> lib -> src and paste in your project
Secound : Go to tree_view.dart
change code in line 18 to this
const TreeView({ Key? key, // add this line @required this.data, this.titleKey = 'title', this.leadingKey = 'leading', this.expanedKey = 'expaned', this.childrenKey = 'children', this.offsetLeft = 24.0, this.titleOnTap, this.leadingOnTap, this.trailingOnTap, }) : super(key: key); // replace with this line
third : Go to tree_node.dart
change code in line 17 to this :
const TreeNode({ Key? key, // add this line this.level = 0, this.expaned = false, this.offsetLeft = 24.0, this.children = const [], this.title = const Text('Title'), this.leading = const IconButton( icon: Icon(Icons.star_border), iconSize: 16, onPressed: null, ), this.trailing = const IconButton( icon: Icon(Icons.expand_more), iconSize: 16, onPressed: null, ), this.titleOnTap, this.leadingOnTap, this.trailingOnTap, }); : super(key: key); // replace with this line
in line 50 add this:
@override // add this line initState() { _isExpaned = widget.expaned; _rotationController = AnimationController( duration: const Duration(milliseconds: 300), vsync: this, ); super.initState(); }
in line 90 and line 102 :
const SizedBox(width: 6.0), // add const Expanded( child: GestureDetector( onTap: () { if (widget.titleOnTap != null && widget.titleOnTap is Function) { widget.titleOnTap(); } }, child: widget.title ?? Container(), ), ), const SizedBox(width: 6.0), // add const Visibility( visible: children.isNotEmpty, // replace with isNotEmpty
in line 136 :
Visibility( visible: children.isNotEmpty && _isExpaned, // replace with isNotEmpty child: Padding( padding: EdgeInsets.only(left: level + 1 * offsetLeft), child: Column( children: widget.children, crossAxisAlignment: CrossAxisAlignment.start, ), ), ),
That's all š š š
It's null safety now!
Hi Guys ... For anyone need to use this library with null safety support .. follow these steps :
First : copy files from root directory -> lib -> src and paste in your project
Secound : Go to tree_view.dart
change code in line 18 to this
third : Go to tree_node.dart
change code in line 17 to this :
in line 50 add this:
in line 90 and line 102 :
in line 136 :
That's all š š š