Skip to content

Commit

Permalink
Merge branch 'misc_updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-brink committed Jun 12, 2024
2 parents 39fa614 + 4adca04 commit d9bcb9e
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 144 deletions.
28 changes: 28 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/tools/linter-rules.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/tools/analysis
21 changes: 7 additions & 14 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
Expand Down Expand Up @@ -64,8 +61,4 @@ android {

flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
}
13 changes: 0 additions & 13 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
30 changes: 22 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.1.2" apply false
id "org.jetbrains.kotlin.android" version "1.6.10" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.17.6 <3.0.0"
sdk: ">=2.17.6 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down
12 changes: 6 additions & 6 deletions lib/drag_and_drop_builder_parameters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ 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:flutter/widgets.dart';

typedef void OnPointerMove(PointerMoveEvent event);
typedef void OnPointerUp(PointerUpEvent event);
typedef void OnPointerDown(PointerDownEvent event);
typedef void OnItemReordered(
typedef OnPointerMove = void Function(PointerMoveEvent event);
typedef OnPointerUp = void Function(PointerUpEvent event);
typedef OnPointerDown = void Function(PointerDownEvent event);
typedef OnItemReordered = void Function(
DragAndDropItem reorderedItem,
DragAndDropItem receiverItem,
);
typedef void OnItemDropOnLastTarget(
typedef OnItemDropOnLastTarget = void Function(
DragAndDropItem newOrReorderedItem,
DragAndDropListInterface parentList,
DragAndDropItemTarget receiver,
);
typedef void OnListReordered(
typedef OnListReordered = void Function(
DragAndDropListInterface reorderedList,
DragAndDropListInterface receiverList,
);
Expand Down
8 changes: 4 additions & 4 deletions lib/drag_and_drop_item_target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ class DragAndDropItemTarget extends StatefulWidget {
final DragAndDropBuilderParameters parameters;
final OnItemDropOnLastTarget onReorderOrAdd;

DragAndDropItemTarget(
const DragAndDropItemTarget(
{required this.child,
required this.onReorderOrAdd,
required this.parameters,
this.parent,
Key? key})
: super(key: key);
super.key});

@override
State<StatefulWidget> createState() => _DragAndDropItemTarget();
Expand Down Expand Up @@ -55,9 +54,10 @@ class _DragAndDropItemTarget extends State<DragAndDropItemTarget>
},
onWillAcceptWithDetails: (details) {
bool accept = true;
if (widget.parameters.itemTargetOnWillAccept != null)
if (widget.parameters.itemTargetOnWillAccept != null) {
accept =
widget.parameters.itemTargetOnWillAccept!(details.data, widget);
}
if (accept && mounted) {
setState(() {
_hoveredDraggable = details.data;
Expand Down
47 changes: 24 additions & 23 deletions lib/drag_and_drop_item_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ class DragAndDropItemWrapper extends StatefulWidget {
final DragAndDropItem child;
final DragAndDropBuilderParameters? parameters;

DragAndDropItemWrapper(
{required this.child, required this.parameters, Key? key})
: super(key: key);
const DragAndDropItemWrapper(
{required this.child, required this.parameters, super.key});

@override
State<StatefulWidget> createState() => _DragAndDropItemWrapper();
Expand All @@ -27,7 +26,7 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
Widget draggable;
if (widget.child.canDrag) {
if (widget.parameters!.itemDragHandle != null) {
Widget feedback = Container(
Widget feedback = SizedBox(
width: widget.parameters!.itemDraggingWidth ?? _containerSize.width,
child: Stack(
children: [
Expand Down Expand Up @@ -68,14 +67,6 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
widget.parameters!.constrainDraggingAxis
? Axis.vertical
: null,
child: MeasureSize(
onSizeChange: (size) {
setState(() {
_dragHandleSize = size!;
});
},
child: widget.parameters!.itemDragHandle,
),
feedback: Transform.translate(
offset: _feedbackContainerOffset(),
child: Material(
Expand All @@ -94,6 +85,14 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
onDragCompleted: () => _setDragging(false),
onDraggableCanceled: (_, __) => _setDragging(false),
onDragEnd: (_) => _setDragging(false),
child: MeasureSize(
onSizeChange: (size) {
setState(() {
_dragHandleSize = size!;
});
},
child: widget.parameters!.itemDragHandle,
),
),
),
);
Expand All @@ -120,25 +119,25 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
widget.parameters!.constrainDraggingAxis
? Axis.vertical
: null,
child: widget.child.child,
feedback: Container(
feedback: SizedBox(
width:
widget.parameters!.itemDraggingWidth ?? _containerSize.width,
child: Material(
color: Colors.transparent,
child: Container(
decoration: widget.parameters!.itemDecorationWhileDragging,
child: Directionality(
textDirection: Directionality.of(context),
child: widget.child.feedbackWidget ?? widget.child.child),
decoration: widget.parameters!.itemDecorationWhileDragging,
),
color: Colors.transparent,
),
),
childWhenDragging: Container(),
onDragStarted: () => _setDragging(true),
onDragCompleted: () => _setDragging(false),
onDraggableCanceled: (_, __) => _setDragging(false),
onDragEnd: (_) => _setDragging(false),
child: widget.child.child,
),
);
} else {
Expand All @@ -150,26 +149,26 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
widget.parameters!.constrainDraggingAxis
? Axis.vertical
: null,
child: widget.child.child,
feedback: Container(
feedback: SizedBox(
width:
widget.parameters!.itemDraggingWidth ?? _containerSize.width,
child: Material(
color: Colors.transparent,
child: Container(
decoration: widget.parameters!.itemDecorationWhileDragging,
child: Directionality(
textDirection: Directionality.of(context),
child: widget.child.feedbackWidget ?? widget.child.child,
),
decoration: widget.parameters!.itemDecorationWhileDragging,
),
color: Colors.transparent,
),
),
childWhenDragging: Container(),
onDragStarted: () => _setDragging(true),
onDragCompleted: () => _setDragging(false),
onDraggableCanceled: (_, __) => _setDragging(false),
onDragEnd: (_) => _setDragging(false),
child: widget.child.child,
),
);
}
Expand Down Expand Up @@ -200,10 +199,10 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
: Container(),
),
Listener(
child: draggable,
onPointerMove: _onPointerMove,
onPointerDown: widget.parameters!.onPointerDown,
onPointerUp: widget.parameters!.onPointerUp,
child: draggable,
),
],
),
Expand All @@ -215,9 +214,10 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
},
onWillAcceptWithDetails: (details) {
bool accept = true;
if (widget.parameters!.itemOnWillAccept != null)
if (widget.parameters!.itemOnWillAccept != null) {
accept = widget.parameters!.itemOnWillAccept!(
details.data, widget.child);
}
if (accept && mounted) {
setState(() {
_hoveredDraggable = details.data;
Expand All @@ -235,8 +235,9 @@ class _DragAndDropItemWrapper extends State<DragAndDropItemWrapper>
onAcceptWithDetails: (details) {
if (mounted) {
setState(() {
if (widget.parameters!.onItemReordered != null)
if (widget.parameters!.onItemReordered != null) {
widget.parameters!.onItemReordered!(details.data, widget.child);
}
_hoveredDraggable = null;
});
}
Expand Down
10 changes: 6 additions & 4 deletions lib/drag_and_drop_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ class DragAndDropList implements DragAndDropListInterface {

/// The child elements that will be contained in this list.
/// It is possible to not provide any children when an empty list is desired.
@override
final List<DragAndDropItem> children;

/// Whether or not this item can be dragged.
/// Set to true if it can be reordered.
/// Set to false if it must remain fixed.
@override
final bool canDrag;
final Key? key;
DragAndDropList({
Expand Down Expand Up @@ -78,7 +80,7 @@ class DragAndDropList implements DragAndDropListInterface {
),
);
if (params.axis == Axis.horizontal) {
intrinsicHeight = Container(
intrinsicHeight = SizedBox(
width: params.listWidth,
child: intrinsicHeight,
);
Expand Down Expand Up @@ -144,7 +146,7 @@ class DragAndDropList implements DragAndDropListInterface {
contents.add(
Expanded(
child: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: verticalAlignment,
mainAxisSize: MainAxisSize.max,
Expand All @@ -157,12 +159,12 @@ class DragAndDropList implements DragAndDropListInterface {
contents.add(
Expanded(
child: SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
contentsWhenEmpty ??
Text(
const Text(
'Empty list',
style: TextStyle(
fontStyle: FontStyle.italic,
Expand Down
Loading

0 comments on commit d9bcb9e

Please sign in to comment.