floating_draggable_advn 1.0.1+1 floating_draggable_advn: ^1.0.1+1 copied to clipboard
A flutter package for floating draggable widget. By this package a developer can implement a widget which can be draggable inside the screen freely.
import 'package:flutter/material.dart';
import 'package:floating_draggable_advn/floating_draggable_advn.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Floating Draggable Widget',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool isShowMessage = true;
@override
void initState() {
Future.delayed(const Duration(seconds: 10), () {
setState(() {
isShowMessage = false;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return FloatingDraggableADVN(
floatingWidget: FloatingActionButton(
onPressed: () {},
child: Image.asset("assets/images/chatbot.png"),
),
iconMessageWidgetHeight: 30,
iconMessageWidgetWidth: 148,
iconMessageWidget: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration:
BoxDecoration(color: Colors.green.shade400.withOpacity(0.6), borderRadius: BorderRadius.circular(12)),
child: Row(
children: [
const Text(
"Bạn có tin nhấn",
style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold),
),
const SizedBox(width: 6),
Image.asset("assets/images/message.png"),
],
),
),
callBackMessage: () {
setState(() {
isShowMessage = false;
});
},
isIconMessage: isShowMessage,
floatingWidgetHeight: 90,
floatingWidgetWidth: 90,
dx: 200,
dy: 300,
deleteWidgetDecoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Colors.white12, Colors.grey],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [.0, 1],
),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
deleteWidget: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(width: 2, color: Colors.black87),
),
child: const Icon(Icons.close, color: Colors.black87),
),
onDeleteWidget: () {
debugPrint('Widget deleted');
},
child: Scaffold(
appBar: AppBar(
title: const Text('Floating Animated Widget'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Floating Animated Widget',
style: Theme.of(context).textTheme.headline6,
),
],
),
),
),
);
}
}