From 5311862d7c53ae1b6a6ac02dcb0e6607e3aced75 Mon Sep 17 00:00:00 2001 From: hovadur Date: Mon, 21 Dec 2020 17:03:22 +0300 Subject: [PATCH 1/7] nullsafety --- example/lib/home.dart | 4 ++-- example/lib/main.dart | 6 ++--- example/pubspec.yaml | 7 +++--- lib/floating_action_bubble.dart | 41 ++++++++++++++++----------------- pubspec.yaml | 4 ++-- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/example/lib/home.dart b/example/lib/home.dart index ffd0326..c01a992 100644 --- a/example/lib/home.dart +++ b/example/lib/home.dart @@ -14,8 +14,8 @@ class Homepage extends StatefulWidget{ class HomepageState extends State with SingleTickerProviderStateMixin{ - Animation _animation; - AnimationController _animationController; + late Animation _animation; + late AnimationController _animationController; @override void initState(){ diff --git a/example/lib/main.dart b/example/lib/main.dart index ff1dbc3..d27955d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,7 +18,7 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + MyHomePage({Key? key, this.title = ''}) : super(key: key); final String title; @override @@ -27,8 +27,8 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State with SingleTickerProviderStateMixin{ - Animation _animation; - AnimationController _animationController; + late Animation _animation; + late AnimationController _animationController; @override void initState(){ 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/lib/floating_action_bubble.dart b/lib/floating_action_bubble.dart index 7bc94f4..42fd215 100644 --- a/lib/floating_action_bubble.dart +++ b/lib/floating_action_bubble.dart @@ -2,23 +2,23 @@ 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}); + {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; + final VoidCallback onPress; final String title; 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; @@ -64,11 +64,11 @@ class _DefaultHeroTag { 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 this.iconColor, + required this.backGroundColor, + required Animation animation, this.herotag, this.iconData, this.animatedIconData, @@ -77,10 +77,10 @@ class FloatingActionBubble extends AnimatedWidget { super(listenable: animation); final List items; - final Function onPress; - final AnimatedIconData animatedIconData; - final Object herotag; - final IconData iconData; + final VoidCallback onPress; + final AnimatedIconData? animatedIconData; + final Object? herotag; + final IconData? iconData; final Color iconColor; final Color backGroundColor; @@ -89,8 +89,7 @@ class FloatingActionBubble extends AnimatedWidget { Widget buildItem(BuildContext context, int index) { final screenWidth = MediaQuery.of(context).size.width; - TextDirection textDirection = - Directionality.of(context) ?? TextDirection.ltr; + TextDirection textDirection = Directionality.of(context); double animationDirection = textDirection == TextDirection.ltr ? -1 : 1; @@ -138,9 +137,9 @@ class FloatingActionBubble extends AnimatedWidget { 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, + icon: animatedIconData!, progress: _animation, ) : Icon( diff --git a/pubspec.yaml b/pubspec.yaml index 90c9c63..f72ca37 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-nullsafety.0 homepage: https://github.com/Darshan0/floating_action_bubble environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: From 92985612c3ce0f7ecfec31d417603840527970dd Mon Sep 17 00:00:00 2001 From: hovadur Date: Fri, 1 Jan 2021 10:34:11 +0300 Subject: [PATCH 2/7] removed some required --- lib/floating_action_bubble.dart | 34 ++++++++++++++------------- test/floating_action_bubble_test.dart | 8 +------ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/lib/floating_action_bubble.dart b/lib/floating_action_bubble.dart index 42fd215..2228cd1 100644 --- a/lib/floating_action_bubble.dart +++ b/lib/floating_action_bubble.dart @@ -1,20 +1,21 @@ 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; + 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 { @@ -58,6 +59,7 @@ class BubbleMenu extends StatelessWidget { class _DefaultHeroTag { const _DefaultHeroTag(); + @override String toString() => ''; } @@ -66,9 +68,9 @@ class FloatingActionBubble extends AnimatedWidget { const FloatingActionBubble({ required this.items, required this.onPress, - required this.iconColor, - required this.backGroundColor, required Animation animation, + this.iconColor, + this.backGroundColor, this.herotag, this.iconData, this.animatedIconData, @@ -81,8 +83,8 @@ class FloatingActionBubble extends AnimatedWidget { final AnimatedIconData? animatedIconData; final Object? herotag; final IconData? iconData; - final Color iconColor; - final Color backGroundColor; + final Color? iconColor; + final Color? backGroundColor; get _animation => listenable; 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() {} From ec0a286ae584243a9fc92a023d1e97510c6b5474 Mon Sep 17 00:00:00 2001 From: hovadur Date: Mon, 25 Jan 2021 13:02:53 +0300 Subject: [PATCH 3/7] lint --- example/lib/home.dart | 142 +++++++++++++++----------------- example/lib/main.dart | 140 ++++++++++++++++--------------- lib/floating_action_bubble.dart | 38 ++++----- 3 files changed, 153 insertions(+), 167 deletions(-) diff --git a/example/lib/home.dart b/example/lib/home.dart index c01a992..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{ - - +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 d27955d..dd3ddbf 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -12,7 +12,9 @@ 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')), ); } } @@ -25,94 +27,90 @@ class MyHomePage extends StatefulWidget { _MyHomePageState createState() => _MyHomePageState(); } -class _MyHomePageState extends State with SingleTickerProviderStateMixin{ - +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/lib/floating_action_bubble.dart b/lib/floating_action_bubble.dart index 2228cd1..9b61e26 100644 --- a/lib/floating_action_bubble.dart +++ b/lib/floating_action_bubble.dart @@ -26,8 +26,8 @@ class BubbleMenu extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialButton( - shape: StadiumBorder(), - padding: EdgeInsets.only(top: 11, bottom: 13, left: 32, right: 32), + shape: const StadiumBorder(), + padding: const 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), @@ -40,11 +40,11 @@ class BubbleMenu extends StatelessWidget { children: [ item.icon != null ? Icon( - item.icon, - color: item.iconColor, - ) + item.icon, + color: item.iconColor, + ) : Container(), - SizedBox( + const SizedBox( width: 10.0, ), Text( @@ -75,7 +75,7 @@ class FloatingActionBubble extends AnimatedWidget { this.iconData, this.animatedIconData, }) : assert((iconData == null && animatedIconData != null) || - (iconData != null && animatedIconData == null)), + (iconData != null && animatedIconData == null)), super(listenable: animation); final List items; @@ -91,9 +91,9 @@ class FloatingActionBubble extends AnimatedWidget { Widget buildItem(BuildContext context, int index) { final screenWidth = MediaQuery.of(context).size.width; - TextDirection textDirection = Directionality.of(context); + final textDirection = Directionality.of(context); - double animationDirection = textDirection == TextDirection.ltr ? -1 : 1; + final animationDirection = textDirection == TextDirection.ltr ? -1 : 1; final transform = Matrix4.translationValues( animationDirection * @@ -127,27 +127,27 @@ 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 && animatedIconData != null ? AnimatedIcon( - icon: animatedIconData!, - progress: _animation, - ) + icon: animatedIconData!, + progress: _animation, + ) : Icon( - iconData, - color: iconColor, - ), + iconData, + color: iconColor, + ), onPressed: onPress, ), ], From 524ce316049a4f61f5b5664a1a1b1447385f990a Mon Sep 17 00:00:00 2001 From: hovadur Date: Thu, 28 Jan 2021 10:21:05 +0300 Subject: [PATCH 4/7] MaterialButton -> ElevatedButton --- lib/floating_action_bubble.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/floating_action_bubble.dart b/lib/floating_action_bubble.dart index 9b61e26..751bcb1 100644 --- a/lib/floating_action_bubble.dart +++ b/lib/floating_action_bubble.dart @@ -25,15 +25,13 @@ class BubbleMenu extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialButton( - shape: const StadiumBorder(), - padding: const 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, From 5521a335092be27da5023ab0496b13460f13d9e8 Mon Sep 17 00:00:00 2001 From: hovadur Date: Sun, 7 Mar 2021 09:29:45 +0300 Subject: [PATCH 5/7] up to 1.2.0 --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index f72ca37..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.2.0-nullsafety.0 +version: 1.2.0 homepage: https://github.com/Darshan0/floating_action_bubble environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: From cd7b90426ea63bef1223a066629f638700b20235 Mon Sep 17 00:00:00 2001 From: hovadur Date: Sat, 27 Mar 2021 08:24:05 +0300 Subject: [PATCH 6/7] fixed the example in the README --- README.md | 154 +++++++++++++++++++++++++++--------------------------- 1 file changed, 76 insertions(+), 78 deletions(-) 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, + )); + } } ``` From 1156ad5d8f498373337f46e8a945c2f2bd5ea474 Mon Sep 17 00:00:00 2001 From: Mohammad Hammadi Date: Tue, 26 Oct 2021 14:46:11 +0300 Subject: [PATCH 7/7] Add mini property to Floating action bubble button --- .idea/libraries/Dart_SDK.xml | 32 +++++++++----- .idea/libraries/Flutter_Plugins.xml | 7 ++++ .idea/workspace.xml | 65 +++++++++++++++++------------ floating_action_bubble.iml | 1 - lib/floating_action_bubble.dart | 3 ++ 5 files changed, 69 insertions(+), 39 deletions(-) create mode 100644 .idea/libraries/Flutter_Plugins.xml 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 + + + + \ No newline at end of file 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 751bcb1..ba66723 100644 --- a/lib/floating_action_bubble.dart +++ b/lib/floating_action_bubble.dart @@ -72,6 +72,7 @@ class FloatingActionBubble extends AnimatedWidget { this.herotag, this.iconData, this.animatedIconData, + this.mini, }) : assert((iconData == null && animatedIconData != null) || (iconData != null && animatedIconData == null)), super(listenable: animation); @@ -83,6 +84,7 @@ class FloatingActionBubble extends AnimatedWidget { final IconData? iconData; final Color? iconColor; final Color? backGroundColor; + final bool? mini; get _animation => listenable; @@ -147,6 +149,7 @@ class FloatingActionBubble extends AnimatedWidget { color: iconColor, ), onPressed: onPress, + mini: mini ?? false, ), ], );