https://github.com/gitsunmin/dot_controller
flutter library dot controller
https://github.com/gitsunmin/dot_controller
dart flutter library
Last synced: 3 months ago
JSON representation
flutter library dot controller
- Host: GitHub
- URL: https://github.com/gitsunmin/dot_controller
- Owner: gitsunmin
- License: mit
- Created: 2023-12-23T14:01:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-17T23:59:06.000Z (over 2 years ago)
- Last Synced: 2025-05-30T02:48:20.098Z (about 1 year ago)
- Topics: dart, flutter, library
- Language: C++
- Homepage:
- Size: 4.14 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# dot_controller

**dot_controller** is a Controller, Navigator, and Selector.
> You can run a function by simply moving Dot. You can also change the color and icon of Dot.
# Usage
## 1. Define Your Dot
you have to create a "Dot" that can move at a point on the screen.
```dart
Scaffold(
...,
body: Stack(
children: [
YourWidget(),
DotController( // <-- this is your Dot
actions: [],
)
],
),
);
```
## 2. Add Your Action
You have to declare "Action," the destination of "Dot."
```dart
Scaffold(
...,
body: Stack(
children: [
YourWidget(),
DotController( // <-- this is your Dot
actions: [ // <--- your Actions
ActionProp(
icon: const Icon(Icons.add),
onAccept: () {
doSomething();
},
),
ActionProp(
icon: const Icon(Icons.remove),
onAccept: onAccept: () {
doSomething();
},
),
ActionProp(
icon: const Icon(Icons.backspace),
onAccept: onAccept: () {
doSomething();
},
),
],
)
],
),
);
```
## 3. Add Your Style
You can style your "Dot" and "Actions".
```dart
Scaffold(
...,
body: Stack(
children: [
YourWidget(),
DotController( // <-- this is your Dot
draggingBackgroundColor: Colors.amber,
stickBackgroundColor: Colors.amber,
actions: [ // <--- your Actions
ActionProp(
icon: const Icon(Icons.add),
backgroundColor: Colors.white,
borderColor: Colors.black,
onAccept: () {
doSomething();
},
),
ActionProp(
icon: const Icon(Icons.remove),
backgroundColor: Colors.red,
borderColor: Colors.black,
onAccept: onAccept: () {
doSomething();
},
),
ActionProp(
icon: const Icon(Icons.backspace),
backgroundColor: Colors.yellow,
borderColor: Colors.black,
onAccept: onAccept: () {
doSomething();
},
),
],
)
],
),
);
```
# Example
```dart
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal,
title: Text(widget.title, style: const TextStyle(color: Colors.white)),
),
body: Stack(
children: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
'Counter',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
DotController(
draggingBackgroundColor: Colors.amber,
stickBackgroundColor: Colors.amber,
actions: [
ActionProp(
icon: const Icon(Icons.add),
backgroundColor: Colors.white,
borderColor: Colors.black,
onAccept: _incrementCounter,
),
ActionProp(
icon: const Icon(Icons.remove),
backgroundColor: Colors.red,
borderColor: Colors.black,
onAccept: _decrementCounter,
),
ActionProp(
icon: const Icon(Icons.backspace),
backgroundColor: Colors.yellow,
borderColor: Colors.black,
onAccept: _initCounter,
),
],
)
],
),
);
}
```

# License
[Apache-2.0 license](./LICENSE)