Skip to content

Commit

Permalink
Merge pull request philip-brink#32 from philip-brink/Refactors
Browse files Browse the repository at this point in the history
Null safety
  • Loading branch information
philip-brink authored Mar 30, 2021
2 parents 0040604 + 69f9a6c commit 524711c
Show file tree
Hide file tree
Showing 25 changed files with 455 additions and 440 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.3.0]

* DragHandle moved to own widget. To create any drag handle, use the new properties `listDragHandle` and `itemDragHandle` in `DragAndDropLists`.
* Support null safety, see [details on migration](https://dart.dev/null-safety/migration-guide)

## [0.2.10] - 14 December 2020

* Bug fix where `listDecorationWhileDragging` wasn't always being applied
Expand Down
5 changes: 2 additions & 3 deletions example/lib/basic_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class BasicExample extends StatefulWidget {
BasicExample({Key key, this.title}) : super(key: key);
final String title;
BasicExample({Key? key}) : super(key: key);

@override
_BasicExample createState() => _BasicExample();
}

class _BasicExample extends State<BasicExample> {
List<DragAndDropList> _contents;
late List<DragAndDropList> _contents;

@override
void initState() {
Expand Down
27 changes: 19 additions & 8 deletions example/lib/drag_handle_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

class DragHandleExample extends StatefulWidget {
DragHandleExample({Key key, this.title}) : super(key: key);
final String title;
DragHandleExample({Key? key}) : super(key: key);

@override
_DragHandleExample createState() => _DragHandleExample();
}

class _DragHandleExample extends State<DragHandleExample> {
List<DragAndDropList> _contents;
late List<DragAndDropList> _contents;

@override
void initState() {
Expand Down Expand Up @@ -116,11 +115,23 @@ class _DragHandleExample extends State<DragHandleExample> {
lastItemTargetHeight: 8,
addLastItemTargetHeightToTop: true,
lastListTargetSize: 40,
dragHandle: Padding(
padding: EdgeInsets.only(right: 10),
child: Icon(
Icons.menu,
color: Colors.black26,
listDragHandle: DragHandle(
verticalAlignment: DragHandleVerticalAlignment.top,
child: Padding(
padding: EdgeInsets.only(right: 10),
child: Icon(
Icons.menu,
color: Colors.black26,
),
),
),
itemDragHandle: DragHandle(
child: Padding(
padding: EdgeInsets.only(right: 10),
child: Icon(
Icons.menu,
color: Colors.black26,
),
),
),
),
Expand Down
17 changes: 10 additions & 7 deletions example/lib/drag_into_list_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ import 'package:drag_and_drop_lists/drag_and_drop_item.dart';
import 'package:drag_and_drop_lists/drag_and_drop_list_interface.dart';
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:example/navigation_drawer.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class DragIntoListExample extends StatefulWidget {
DragIntoListExample({Key key, this.title}) : super(key: key);
final String title;
DragIntoListExample({Key? key}) : super(key: key);

@override
_DragIntoListExample createState() => _DragIntoListExample();
}

class _DragIntoListExample extends State<DragIntoListExample> {
List<DragAndDropList> _contents = List<DragAndDropList>();
List<DragAndDropList> _contents = <DragAndDropList>[];

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -55,7 +53,12 @@ class _DragIntoListExample extends State<DragIntoListExample> {
child: Draggable<DragAndDropListInterface>(
feedback: Icon(Icons.assignment),
child: Icon(Icons.assignment),
data: DragAndDropList(header: Text('New default list')),
data: DragAndDropList(
header: Text(
'New default list',
),
children: <DragAndDropItem>[],
),
),
),
),
Expand Down Expand Up @@ -109,9 +112,9 @@ class _DragIntoListExample extends State<DragIntoListExample> {
print('adding new list');
setState(() {
if (listIndex == -1)
_contents.add(newList);
_contents.add(newList as DragAndDropList);
else
_contents.insert(listIndex, newList);
_contents.insert(listIndex, newList as DragAndDropList);
});
}
}
7 changes: 3 additions & 4 deletions example/lib/expansion_tile_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

class ExpansionTileExample extends StatefulWidget {
ExpansionTileExample({Key key, this.title}) : super(key: key);
final String title;
ExpansionTileExample({Key? key}) : super(key: key);

@override
_ListTileExample createState() => _ListTileExample();
Expand All @@ -16,11 +15,11 @@ class ExpansionTileExample extends StatefulWidget {
class InnerList {
final String name;
List<String> children;
InnerList({this.name, this.children});
InnerList({required this.name, required this.children});
}

class _ListTileExample extends State<ExpansionTileExample> {
List<InnerList> _lists;
late List<InnerList> _lists;

@override
void initState() {
Expand Down
5 changes: 2 additions & 3 deletions example/lib/fixed_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class FixedExample extends StatefulWidget {
FixedExample({Key key, this.title}) : super(key: key);
final String title;
FixedExample({Key? key}) : super(key: key);

@override
_FixedExample createState() => _FixedExample();
}

class _FixedExample extends State<FixedExample> {
List<DragAndDropList> _contents;
late List<DragAndDropList> _contents;

@override
void initState() {
Expand Down
7 changes: 3 additions & 4 deletions example/lib/horizontal_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class HorizontalExample extends StatefulWidget {
HorizontalExample({Key key, this.title}) : super(key: key);
final String title;
HorizontalExample({Key? key}) : super(key: key);

@override
_HorizontalExample createState() => _HorizontalExample();
Expand All @@ -15,11 +14,11 @@ class HorizontalExample extends StatefulWidget {
class InnerList {
final String name;
List<String> children;
InnerList({this.name, this.children});
InnerList({required this.name, required this.children});
}

class _HorizontalExample extends State<HorizontalExample> {
List<InnerList> _lists;
late List<InnerList> _lists;

@override
void initState() {
Expand Down
8 changes: 3 additions & 5 deletions example/lib/list_tile_example.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:example/navigation_drawer.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

class ListTileExample extends StatefulWidget {
ListTileExample({Key key, this.title}) : super(key: key);
final String title;
ListTileExample({Key? key}) : super(key: key);

@override
_ListTileExample createState() => _ListTileExample();
}

class _ListTileExample extends State<ListTileExample> {
List<DragAndDropList> _contents;
late List<DragAndDropList> _contents;

@override
void initState() {
Expand Down Expand Up @@ -110,7 +108,7 @@ class _ListTileExample extends State<ListTileExample> {
Text(
'Empty List',
style: TextStyle(
color: Theme.of(context).textTheme.caption.color,
color: Theme.of(context).textTheme.caption!.color,
fontStyle: FontStyle.italic),
),
Expanded(
Expand Down
6 changes: 2 additions & 4 deletions example/lib/sliver_example.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import 'package:drag_and_drop_lists/drag_and_drop_item.dart';
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:example/navigation_drawer.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class SliverExample extends StatefulWidget {
SliverExample({Key key, this.title}) : super(key: key);
final String title;
SliverExample({Key? key}) : super(key: key);

@override
_SliverExample createState() => _SliverExample();
}

class _SliverExample extends State<SliverExample> {
List<DragAndDropList> _contents;
late List<DragAndDropList> _contents;
ScrollController _scrollController = ScrollController();

@override
Expand Down
Loading

0 comments on commit 524711c

Please sign in to comment.