v2.3.0floating_draggable_widget
Um pacote Flutter para widget flutuante arrastável. Com este pacote, um desenvolvedor pode implementar um widget que pode ser arrastado livremente na tela.
um pacote do Flutter para widget flutuante
{"sdk":"flutter"}{"sdk":"flutter"}^2.0.1Texto original em inglês. Visite o GitHub para a versão atual.
Without auto align Initially "autoAlign" is false.
autoAlign = false
https://raw.githubusercontent.com/Smueez/assets/main/floating_widget.gif
Auto align activated Add this to your code.
autoAlign = true
https://raw.githubusercontent.com/Smueez/assets/main/autoAlign.gif
Deletion of the widget Add this to your code.
deleteWidget: Icon(Icons.cancel),
https://github.com/Smueez/assets/blob/11b723fc6e19e4148969d70ef96fce0877196ec5/ezgif-5-0a5c2b8cd0.gif
add this in your pubspec.yaml
floating_draggable_widget: ^latest_version
This is the constructor of the class.
FloatingDraggableWidget({
required this.mainScreenWidget,
required this.floatingWidget,
required this.floatingWidgetWidth,
required this.floatingWidgetHeight,
this.dy,
this.dx,
this.screenHeight,
this.screenWidth,
this.speed,
this.isDraggble = true,
this.autoAlign = false,
this.deleteWidgetAlignment = Alignment.bottomCenter,
this.deleteWidgetAnimationDuration = 200,
this.hasDeleteWidgetAnimationDuration = 300,
this.deleteWidgetAnimationCurve = Curves.easeIn,
this.deleteWidgetHeight = 50,
this.deleteWidgetWidth = 50,
this.isCollidingDeleteWidgetHeight = 70,
this.isCollidingDeleteWidgetWidth = 70,
this.deleteWidgetDecoration,
this.deleteWidgetPadding = const EdgeInsets.only(bottom: 8),
this.onDragging,
this.widgetWhenDragging,
});
import 'package:flutter/material.dart';
import 'package:floating_animated_widget/floating_draggable_widget.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return FloatingDraggableWidget(
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
),
floatingWidget: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
floatingWidgetHeight: 40,
floatingWidgetWidth: 40,
dx: 200,
dy: 300
);
}
}