diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index 038f772..e59fc47 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,17 +1,27 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml
new file mode 100644
index 0000000..b0f6971
--- /dev/null
+++ b/.idea/libraries/Flutter_Plugins.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5b3388c..ad2111c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,36 +1,47 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+ 1635248548146
+
+
+ 1635248548146
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index fbcec1a..bb4ba1d 100644
--- a/README.md
+++ b/README.md
@@ -29,109 +29,107 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
- home: Directionality(textDirection: TextDirection.rtl, child: MyHomePage(title: 'Floating Action Bubble Demo')),
+ home: Directionality(
+ textDirection: TextDirection.rtl,
+ child: MyHomePage(title: 'Floating Action Bubble Demo')),
);
}
}
class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+ MyHomePage({Key? key, this.title = ''}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
-class _MyHomePageState extends State with SingleTickerProviderStateMixin{
-
- Animation _animation;
- AnimationController _animationController;
+class _MyHomePageState extends State
+ with SingleTickerProviderStateMixin {
+ late Animation _animation;
+ late AnimationController _animationController;
@override
- void initState(){
-
+ void initState() {
_animationController = AnimationController(
vsync: this,
- duration: Duration(milliseconds: 260),
+ duration: const Duration(milliseconds: 260),
);
- final curvedAnimation = CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
+ final curvedAnimation =
+ CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
_animation = Tween(begin: 0, end: 1).animate(curvedAnimation);
-
-
- super.initState();
-
+ super.initState();
}
-
+
@override
Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(widget.title),
- ),
-
- floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
-
- //Init Floating Action Bubble
- floatingActionButton: FloatingActionBubble(
- // Menu items
- items: [
-
- // Floating action menu item
- Bubble(
- title:"Settings",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.settings,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- // Floating action menu item
- Bubble(
- title:"Profile",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.people,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- //Floating action menu item
- Bubble(
- title:"Home",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.home,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context) => Homepage()));
- _animationController.reverse();
- },
- ),
- ],
-
- // animation controller
- animation: _animation,
-
- // On pressed change animation state
- onPress: () => _animationController.isCompleted
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(widget.title),
+ ),
+ floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
+
+ //Init Floating Action Bubble
+ floatingActionButton: FloatingActionBubble(
+ // Menu items
+ items: [
+ // Floating action menu item
+ Bubble(
+ title: 'Settings',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.settings,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ // Floating action menu item
+ Bubble(
+ title: 'Profile',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.people,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ //Floating action menu item
+ Bubble(
+ title: 'Home',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.home,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (BuildContext context) => Homepage()));
+ _animationController.reverse();
+ },
+ ),
+ ],
+
+ // animation controller
+ animation: _animation,
+
+ // On pressed change animation state
+ onPress: () => _animationController.isCompleted
? _animationController.reverse()
: _animationController.forward(),
-
- // Floating Action button Icon color
- iconColor: Colors.blue,
-
- // Flaoting Action button Icon
- iconData: Icons.ac_unit,
- backGroundColor: Colors.white,
- )
- );
- }
+ // Floating Action button Icon color
+ iconColor: Colors.blue,
+
+ // Floating Action button Icon
+ iconData: Icons.ac_unit,
+ backGroundColor: Colors.white,
+ ));
+ }
}
```
diff --git a/example/lib/home.dart b/example/lib/home.dart
index ffd0326..8ab4782 100644
--- a/example/lib/home.dart
+++ b/example/lib/home.dart
@@ -2,105 +2,93 @@ import 'package:floating_action_bubble/floating_action_bubble.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
-class Homepage extends StatefulWidget{
+class Homepage extends StatefulWidget {
@override
HomepageState createState() {
return HomepageState();
}
-
}
-
-class HomepageState extends State with SingleTickerProviderStateMixin{
-
-
- Animation _animation;
- AnimationController _animationController;
+class HomepageState extends State
+ with SingleTickerProviderStateMixin {
+ late Animation _animation;
+ late AnimationController _animationController;
@override
- void initState(){
-
+ void initState() {
_animationController = AnimationController(
vsync: this,
- duration: Duration(milliseconds: 260),
+ duration: const Duration(milliseconds: 260),
);
- final curvedAnimation = CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
+ final curvedAnimation =
+ CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
_animation = Tween(begin: 0, end: 1).animate(curvedAnimation);
-
- super.initState();
-
+ super.initState();
}
-
+
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(
- title: Text("HeroTag Example"),
- ),
-
- floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
-
- //Init Floating Action Bubble
- floatingActionButton: FloatingActionBubble(
- // Menu items
- items: [
-
- // Floating action menu item
- Bubble(
- title:"Settings",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.settings,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- // Floating action menu item
- Bubble(
- title:"Profile",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.people,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- //Floating action menu item
- Bubble(
- title:"Home",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.home,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- ],
-
- // animation controller
- animation: _animation,
-
- // On pressed change animation state
- onPress: () => _animationController.isCompleted
+ appBar: AppBar(
+ title: const Text('HeroTag Example'),
+ ),
+ floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
+
+ //Init Floating Action Bubble
+ floatingActionButton: FloatingActionBubble(
+ // Menu items
+ items: [
+ // Floating action menu item
+ Bubble(
+ title: 'Settings',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.settings,
+ titleStyle: TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ // Floating action menu item
+ Bubble(
+ title: 'Profile',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.people,
+ titleStyle: TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ //Floating action menu item
+ Bubble(
+ title: 'Home',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.home,
+ titleStyle: TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ ],
+
+ // animation controller
+ animation: _animation,
+
+ // On pressed change animation state
+ onPress: () => _animationController.isCompleted
? _animationController.reverse()
: _animationController.forward(),
-
- // Floating Action button Icon color
- iconColor: Colors.blue,
-
- // Flaoting Action button Icon
- iconData: Icons.ac_unit,
- backGroundColor: Colors.white,
- )
+ // Floating Action button Icon color
+ iconColor: Colors.blue,
- );
+ // Floating Action button Icon
+ iconData: Icons.ac_unit,
+ backGroundColor: Colors.white,
+ ));
}
-
-
-}
\ No newline at end of file
+}
diff --git a/example/lib/main.dart b/example/lib/main.dart
index ff1dbc3..dd3ddbf 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -12,107 +12,105 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
primarySwatch: Colors.blue,
),
- home: Directionality(textDirection: TextDirection.rtl, child: MyHomePage(title: 'Floating Action Bubble Demo')),
+ home: Directionality(
+ textDirection: TextDirection.rtl,
+ child: MyHomePage(title: 'Floating Action Bubble Demo')),
);
}
}
class MyHomePage extends StatefulWidget {
- MyHomePage({Key key, this.title}) : super(key: key);
+ MyHomePage({Key? key, this.title = ''}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
-class _MyHomePageState extends State with SingleTickerProviderStateMixin{
-
- Animation _animation;
- AnimationController _animationController;
+class _MyHomePageState extends State
+ with SingleTickerProviderStateMixin {
+ late Animation _animation;
+ late AnimationController _animationController;
@override
- void initState(){
-
+ void initState() {
_animationController = AnimationController(
vsync: this,
- duration: Duration(milliseconds: 260),
+ duration: const Duration(milliseconds: 260),
);
- final curvedAnimation = CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
+ final curvedAnimation =
+ CurvedAnimation(curve: Curves.easeInOut, parent: _animationController);
_animation = Tween(begin: 0, end: 1).animate(curvedAnimation);
-
-
- super.initState();
-
+ super.initState();
}
-
+
@override
Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text(widget.title),
- ),
-
- floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
-
- //Init Floating Action Bubble
- floatingActionButton: FloatingActionBubble(
- // Menu items
- items: [
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(widget.title),
+ ),
+ floatingActionButtonLocation: FloatingActionButtonLocation.endDocked,
- // Floating action menu item
- Bubble(
- title:"Settings",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.settings,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- // Floating action menu item
- Bubble(
- title:"Profile",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.people,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- _animationController.reverse();
- },
- ),
- //Floating action menu item
- Bubble(
- title:"Home",
- iconColor :Colors.white,
- bubbleColor : Colors.blue,
- icon:Icons.home,
- titleStyle:TextStyle(fontSize: 16 , color: Colors.white),
- onPress: () {
- Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context) => Homepage()));
- _animationController.reverse();
- },
- ),
- ],
+ //Init Floating Action Bubble
+ floatingActionButton: FloatingActionBubble(
+ // Menu items
+ items: [
+ // Floating action menu item
+ Bubble(
+ title: 'Settings',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.settings,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ // Floating action menu item
+ Bubble(
+ title: 'Profile',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.people,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ _animationController.reverse();
+ },
+ ),
+ //Floating action menu item
+ Bubble(
+ title: 'Home',
+ iconColor: Colors.white,
+ bubbleColor: Colors.blue,
+ icon: Icons.home,
+ titleStyle: const TextStyle(fontSize: 16, color: Colors.white),
+ onPress: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (BuildContext context) => Homepage()));
+ _animationController.reverse();
+ },
+ ),
+ ],
- // animation controller
- animation: _animation,
+ // animation controller
+ animation: _animation,
- // On pressed change animation state
- onPress: () => _animationController.isCompleted
+ // On pressed change animation state
+ onPress: () => _animationController.isCompleted
? _animationController.reverse()
: _animationController.forward(),
-
- // Floating Action button Icon color
- iconColor: Colors.blue,
- // Flaoting Action button Icon
- iconData: Icons.ac_unit,
- backGroundColor: Colors.white,
- )
- );
- }
+ // Floating Action button Icon color
+ iconColor: Colors.blue,
+ // Floating Action button Icon
+ iconData: Icons.ac_unit,
+ backGroundColor: Colors.white,
+ ));
+ }
}
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 6e2e1ae..5823367 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -14,7 +14,7 @@ description: A new Flutter project.
version: 1.0.0+1
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
@@ -22,8 +22,9 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.2
- floating_action_bubble : 1.1.2
+ cupertino_icons: ^1.0.2
+ floating_action_bubble :
+ path: ..
dev_dependencies:
flutter_test:
diff --git a/floating_action_bubble.iml b/floating_action_bubble.iml
index 8d48a06..8ef82f3 100644
--- a/floating_action_bubble.iml
+++ b/floating_action_bubble.iml
@@ -12,7 +12,6 @@
-
diff --git a/lib/floating_action_bubble.dart b/lib/floating_action_bubble.dart
index 7bc94f4..ba66723 100644
--- a/lib/floating_action_bubble.dart
+++ b/lib/floating_action_bubble.dart
@@ -1,49 +1,48 @@
import 'package:flutter/material.dart';
class Bubble {
- const Bubble(
- {@required this.title,
- @required this.titleStyle,
- @required this.iconColor,
- @required this.bubbleColor,
- @required this.icon,
- @required this.onPress});
-
- final IconData icon;
- final Color iconColor;
- final Color bubbleColor;
- final Function onPress;
+ const Bubble({
+ required this.title,
+ required this.onPress,
+ this.titleStyle,
+ this.iconColor,
+ this.bubbleColor,
+ this.icon,
+ });
+
+ final IconData? icon;
+ final Color? iconColor;
+ final Color? bubbleColor;
+ final VoidCallback onPress;
final String title;
- final TextStyle titleStyle;
+ final TextStyle? titleStyle;
}
class BubbleMenu extends StatelessWidget {
- const BubbleMenu(this.item, {Key key}) : super(key: key);
+ const BubbleMenu(this.item, {Key? key}) : super(key: key);
final Bubble item;
@override
Widget build(BuildContext context) {
- return MaterialButton(
- shape: StadiumBorder(),
- padding: EdgeInsets.only(top: 11, bottom: 13, left: 32, right: 32),
- color: item.bubbleColor,
- splashColor: Colors.grey.withOpacity(0.1),
- highlightColor: Colors.grey.withOpacity(0.1),
- elevation: 2,
- highlightElevation: 2,
- disabledColor: item.bubbleColor,
+ return ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ shape: const StadiumBorder(),
+ padding:
+ const EdgeInsets.only(top: 11, bottom: 13, left: 32, right: 32),
+ elevation: 2,
+ primary: item.bubbleColor),
onPressed: item.onPress,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
item.icon != null
? Icon(
- item.icon,
- color: item.iconColor,
- )
+ item.icon,
+ color: item.iconColor,
+ )
: Container(),
- SizedBox(
+ const SizedBox(
width: 10.0,
),
Text(
@@ -58,41 +57,43 @@ class BubbleMenu extends StatelessWidget {
class _DefaultHeroTag {
const _DefaultHeroTag();
+
@override
String toString() => '';
}
class FloatingActionBubble extends AnimatedWidget {
const FloatingActionBubble({
- @required this.items,
- @required this.onPress,
- @required this.iconColor,
- @required this.backGroundColor,
- @required Animation animation,
+ required this.items,
+ required this.onPress,
+ required Animation animation,
+ this.iconColor,
+ this.backGroundColor,
this.herotag,
this.iconData,
this.animatedIconData,
+ this.mini,
}) : assert((iconData == null && animatedIconData != null) ||
- (iconData != null && animatedIconData == null)),
+ (iconData != null && animatedIconData == null)),
super(listenable: animation);
final List items;
- final Function onPress;
- final AnimatedIconData animatedIconData;
- final Object herotag;
- final IconData iconData;
- final Color iconColor;
- final Color backGroundColor;
+ final VoidCallback onPress;
+ final AnimatedIconData? animatedIconData;
+ final Object? herotag;
+ final IconData? iconData;
+ final Color? iconColor;
+ final Color? backGroundColor;
+ final bool? mini;
get _animation => listenable;
Widget buildItem(BuildContext context, int index) {
final screenWidth = MediaQuery.of(context).size.width;
- TextDirection textDirection =
- Directionality.of(context) ?? TextDirection.ltr;
+ final textDirection = Directionality.of(context);
- double animationDirection = textDirection == TextDirection.ltr ? -1 : 1;
+ final animationDirection = textDirection == TextDirection.ltr ? -1 : 1;
final transform = Matrix4.translationValues(
animationDirection *
@@ -126,28 +127,29 @@ class FloatingActionBubble extends AnimatedWidget {
ignoring: _animation.value == 0,
child: ListView.separated(
shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- separatorBuilder: (_, __) => SizedBox(height: 12.0),
- padding: EdgeInsets.symmetric(vertical: 12),
+ physics: const NeverScrollableScrollPhysics(),
+ separatorBuilder: (_, __) => const SizedBox(height: 12.0),
+ padding: const EdgeInsets.symmetric(vertical: 12),
itemCount: items.length,
itemBuilder: buildItem,
),
),
FloatingActionButton(
- heroTag: herotag == null ? const _DefaultHeroTag() : herotag,
+ heroTag: herotag ?? const _DefaultHeroTag(),
backgroundColor: backGroundColor,
// iconData is mutually exclusive with animatedIconData
// only 1 can be null at the time
- child: iconData == null
+ child: iconData == null && animatedIconData != null
? AnimatedIcon(
- icon: animatedIconData,
- progress: _animation,
- )
+ icon: animatedIconData!,
+ progress: _animation,
+ )
: Icon(
- iconData,
- color: iconColor,
- ),
+ iconData,
+ color: iconColor,
+ ),
onPressed: onPress,
+ mini: mini ?? false,
),
],
);
diff --git a/pubspec.yaml b/pubspec.yaml
index 90c9c63..4db15cc 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,10 +1,10 @@
name: floating_action_bubble
description: A animated menu using a floating action button , the aesthetic of the menu items are fully customisable
-version: 1.1.2
+version: 1.2.0
homepage: https://github.com/Darshan0/floating_action_bubble
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
diff --git a/test/floating_action_bubble_test.dart b/test/floating_action_bubble_test.dart
index e8b0ef5..ab73b3a 100644
--- a/test/floating_action_bubble_test.dart
+++ b/test/floating_action_bubble_test.dart
@@ -1,7 +1 @@
-import 'package:flutter_test/flutter_test.dart';
-
-import 'package:floating_action_bubble/floating_action_bubble.dart';
-
-void main() {
-
-}
+void main() {}