Skip to content

Commit

Permalink
Make analyzer happy
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-brink committed Aug 4, 2022
1 parent e450da3 commit 76ff8ef
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 144 deletions.
14 changes: 6 additions & 8 deletions example/lib/basic_example.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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/material.dart';
import 'package:flutter/widgets.dart';

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

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

class _BasicExample extends State<BasicExample> {
Expand All @@ -22,15 +20,15 @@ class _BasicExample extends State<BasicExample> {
return DragAndDropList(
header: Row(
children: <Widget>[
Expanded(
const Expanded(
flex: 1,
child: Divider(),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: Text('Header $index'),
),
Expanded(
const Expanded(
flex: 1,
child: Divider(),
),
Expand All @@ -55,9 +53,9 @@ class _BasicExample extends State<BasicExample> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Basic'),
title: const Text('Basic'),
),
drawer: NavigationDrawer(),
drawer: const NavigationDrawer(),
body: DragAndDropLists(
children: _contents,
onItemReorder: _onItemReorder,
Expand Down
32 changes: 15 additions & 17 deletions example/lib/drag_handle_example.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:example/navigation_drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

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

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

class _DragHandleExample extends State<DragHandleExample> {
Expand All @@ -25,10 +23,10 @@ class _DragHandleExample extends State<DragHandleExample> {
Row(
children: [
Padding(
padding: EdgeInsets.only(left: 8, bottom: 4),
padding: const EdgeInsets.only(left: 8, bottom: 4),
child: Text(
'Header $index',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
),
],
Expand All @@ -40,7 +38,7 @@ class _DragHandleExample extends State<DragHandleExample> {
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
child: Text(
'Sub $index.1',
),
Expand All @@ -52,7 +50,7 @@ class _DragHandleExample extends State<DragHandleExample> {
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
child: Text(
'Sub $index.2',
),
Expand All @@ -64,7 +62,7 @@ class _DragHandleExample extends State<DragHandleExample> {
child: Row(
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 8, horizontal: 12),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
child: Text(
'Sub $index.3',
),
Expand All @@ -79,19 +77,19 @@ class _DragHandleExample extends State<DragHandleExample> {

@override
Widget build(BuildContext context) {
var backgroundColor = Color.fromARGB(255, 243, 242, 248);
var backgroundColor = const Color.fromARGB(255, 243, 242, 248);

return Scaffold(
backgroundColor: backgroundColor,
appBar: AppBar(
title: Text('Drag Handle'),
title: const Text('Drag Handle'),
),
drawer: NavigationDrawer(),
drawer: const NavigationDrawer(),
body: DragAndDropLists(
children: _contents,
onItemReorder: _onItemReorder,
onListReorder: _onListReorder,
listPadding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
listPadding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
itemDivider: Divider(
thickness: 2,
height: 2,
Expand All @@ -104,18 +102,18 @@ class _DragHandleExample extends State<DragHandleExample> {
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 3,
offset: Offset(0, 0), // changes position of shadow
offset: const Offset(0, 0), // changes position of shadow
),
],
),
listInnerDecoration: BoxDecoration(
color: Theme.of(context).canvasColor,
borderRadius: BorderRadius.all(Radius.circular(8.0)),
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
),
lastItemTargetHeight: 8,
addLastItemTargetHeightToTop: true,
lastListTargetSize: 40,
listDragHandle: DragHandle(
listDragHandle: const DragHandle(
verticalAlignment: DragHandleVerticalAlignment.top,
child: Padding(
padding: EdgeInsets.only(right: 10),
Expand All @@ -125,7 +123,7 @@ class _DragHandleExample extends State<DragHandleExample> {
),
),
),
itemDragHandle: DragHandle(
itemDragHandle: const DragHandle(
child: Padding(
padding: EdgeInsets.only(right: 10),
child: Icon(
Expand Down
38 changes: 18 additions & 20 deletions example/lib/drag_into_list_example.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
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/material.dart';
import 'package:flutter/widgets.dart';

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

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

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

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Drag Into List'),
title: const Text('Drag Into List'),
),
drawer: NavigationDrawer(),
drawer: const NavigationDrawer(),
body: Column(
children: <Widget>[
Flexible(
Expand All @@ -32,7 +30,7 @@ class _DragIntoListExample extends State<DragIntoListExample> {
onListReorder: _onListReorder,
onItemAdd: _onItemAdd,
onListAdd: _onListAdd,
listGhost: Container(
listGhost: const SizedBox(
height: 50,
width: 100,
child: Center(
Expand All @@ -51,14 +49,14 @@ class _DragIntoListExample extends State<DragIntoListExample> {
color: Colors.pink,
child: Center(
child: Draggable<DragAndDropListInterface>(
feedback: Icon(Icons.assignment),
child: Icon(Icons.assignment),
feedback: const Icon(Icons.assignment),
data: DragAndDropList(
header: Text(
header: const Text(
'New default list',
),
children: <DragAndDropItem>[],
),
child: const Icon(Icons.assignment),
),
),
),
Expand All @@ -68,9 +66,9 @@ class _DragIntoListExample extends State<DragIntoListExample> {
color: Colors.orange,
child: Center(
child: Draggable<DragAndDropItem>(
feedback: Icon(Icons.photo),
child: Icon(Icons.photo),
data: DragAndDropItem(child: Text('New default item')),
feedback: const Icon(Icons.photo),
data: DragAndDropItem(child: const Text('New default item')),
child: const Icon(Icons.photo),
),
),
),
Expand Down Expand Up @@ -99,22 +97,22 @@ class _DragIntoListExample extends State<DragIntoListExample> {
}

_onItemAdd(DragAndDropItem newItem, int listIndex, int itemIndex) {
print('adding new item');
setState(() {
if (itemIndex == -1)
if (itemIndex == -1) {
_contents[listIndex].children.add(newItem);
else
} else {
_contents[listIndex].children.insert(itemIndex, newItem);
}
});
}

_onListAdd(DragAndDropListInterface newList, int listIndex) {
print('adding new list');
setState(() {
if (listIndex == -1)
if (listIndex == -1) {
_contents.add(newList as DragAndDropList);
else
} else {
_contents.insert(listIndex, newList as DragAndDropList);
}
});
}
}
17 changes: 7 additions & 10 deletions example/lib/expansion_tile_example.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import 'package:drag_and_drop_lists/drag_and_drop_list_expansion.dart';
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
import 'package:example/navigation_drawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

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

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

class InnerList {
Expand Down Expand Up @@ -37,9 +34,9 @@ class _ListTileExample extends State<ExpansionTileExample> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Expansion Tiles'),
title: const Text('Expansion Tiles'),
),
drawer: NavigationDrawer(),
drawer: const NavigationDrawer(),
body: DragAndDropLists(
children: List.generate(_lists.length, (index) => _buildList(index)),
onItemReorder: _onItemReorder,
Expand All @@ -49,12 +46,12 @@ class _ListTileExample extends State<ExpansionTileExample> {
padding: const EdgeInsets.symmetric(vertical: 30.0),
child: Center(
child: Container(
padding: EdgeInsets.symmetric(vertical: 30.0, horizontal: 100.0),
padding: const EdgeInsets.symmetric(vertical: 30.0, horizontal: 100.0),
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.circular(7.0),
),
child: Icon(Icons.add_box),
child: const Icon(Icons.add_box),
),
),
),
Expand All @@ -67,7 +64,7 @@ class _ListTileExample extends State<ExpansionTileExample> {
return DragAndDropListExpansion(
title: Text('List ${innerList.name}'),
subtitle: Text('Subtitle ${innerList.name}'),
leading: Icon(Icons.ac_unit),
leading: const Icon(Icons.ac_unit),
children: List.generate(innerList.children.length,
(index) => _buildItem(innerList.children[index])),
listKey: ObjectKey(innerList),
Expand Down
14 changes: 6 additions & 8 deletions example/lib/fixed_example.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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/material.dart';
import 'package:flutter/widgets.dart';

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

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

class _FixedExample extends State<FixedExample> {
Expand All @@ -22,7 +20,7 @@ class _FixedExample extends State<FixedExample> {
return DragAndDropList(
header: Row(
children: <Widget>[
Expanded(
const Expanded(
flex: 1,
child: Divider(),
),
Expand All @@ -32,7 +30,7 @@ class _FixedExample extends State<FixedExample> {
? 'Header $index : Non-Draggable'
: 'Header $index'),
),
Expanded(
const Expanded(
flex: 1,
child: Divider(),
),
Expand All @@ -59,9 +57,9 @@ class _FixedExample extends State<FixedExample> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Fixed Items'),
title: const Text('Fixed Items'),
),
drawer: NavigationDrawer(),
drawer: const NavigationDrawer(),
body: DragAndDropLists(
children: _contents,
onItemReorder: _onItemReorder,
Expand Down
Loading

0 comments on commit 76ff8ef

Please sign in to comment.