diff --git a/CHANGELOG.md b/CHANGELOG.md index c968ba8..a612248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,4 +38,8 @@ * Added description -* Removed dependency from Dart-dev \ No newline at end of file +* Removed dependency from Dart-dev + +## [0.2.1] - 08/03/2021 + +* Migrate to dart null safety \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 5b32e98..b4fa4cc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -26,7 +26,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); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect @@ -37,7 +37,7 @@ class MyHomePage extends StatefulWidget { // used by the build method of the State. Fields in a Widget subclass are // always marked "final". - final String title; + final String? title; @override _MyHomePageState createState() => new _MyHomePageState(); @@ -93,7 +93,7 @@ class _MyHomePageState extends State { return new Scaffold( appBar: new AppBar( - title: new Text(widget.title), + title: new Text(widget.title!), ), //Using a Stack will assure that the Dialer will appear at the end of your layout body: new Stack( diff --git a/lib/src/fab_dialer.dart b/lib/src/fab_dialer.dart index 13c7102..db74e9a 100644 --- a/lib/src/fab_dialer.dart +++ b/lib/src/fab_dialer.dart @@ -25,9 +25,9 @@ class FabDialerState extends State with TickerProviderStateMixin { final Color _fabColor; final Icon _fabIcon; final AnimationStyle _fabAnimationStyle; - List _fabMenuItems; + late List _fabMenuItems; - AnimationController _controller; + late AnimationController _controller; @override void initState() { @@ -43,7 +43,7 @@ class FabDialerState extends State with TickerProviderStateMixin { } void setFabMenu(List fabMenuList) { - List fabMenuItems = new List(); + List fabMenuItems = new List.empty(); for (int i = 0; i < _fabMiniMenuItemList.length; i++) { fabMenuItems.add(new FabMenuMiniItemWidget( tooltip: _fabMiniMenuItemList[i].tooltip, diff --git a/lib/src/fab_menu_item.dart b/lib/src/fab_menu_item.dart index 8e889f2..e9c119e 100644 --- a/lib/src/fab_menu_item.dart +++ b/lib/src/fab_menu_item.dart @@ -6,14 +6,14 @@ typedef void HideWidget(); class FabMiniMenuItem { double elevation; - String text; - Icon icon; - ImageProvider image; - Color fabColor; - Color chipColor; + String? text; + Icon? icon; + ImageProvider? image; + Color? fabColor; + Color? chipColor; String tooltip; - Color textColor; - AnimationStyle animationStyle; + Color? textColor; + AnimationStyle? animationStyle; OnFabMiniMenuItemPressed onPressed; bool hideOnClick; @@ -59,7 +59,7 @@ class FabMiniMenuItem { class FabMenuMiniItemWidget extends StatelessWidget { const FabMenuMiniItemWidget( - {Key key, + {Key? key, this.elevation, this.text, this.icon, @@ -75,22 +75,22 @@ class FabMenuMiniItemWidget extends StatelessWidget { this.animationStyle, this.itemCount}) : super(key: key); - final double elevation; - final String text; - final Icon icon; - final ImageProvider image; - final Color fabColor; - final Color chipColor; - final String tooltip; - final Color textColor; - final int index; - final int itemCount; - final OnFabMiniMenuItemPressed onPressed; - final HideWidget hideWidget; - final AnimationController controller; - final AnimationStyle animationStyle; + final double? elevation; + final String? text; + final Icon? icon; + final ImageProvider? image; + final Color? fabColor; + final Color? chipColor; + final String? tooltip; + final Color? textColor; + final int? index; + final int? itemCount; + final OnFabMiniMenuItemPressed? onPressed; + final HideWidget? hideWidget; + final AnimationController? controller; + final AnimationStyle? animationStyle; - Widget _buildAnimation(BuildContext context, Widget child) { + Widget _buildAnimation(BuildContext context, Widget? child) { final double deviceHeight = MediaQuery.of(context).size.height; switch (animationStyle) { @@ -103,7 +103,7 @@ class FabMenuMiniItemWidget extends StatelessWidget { ) .animate( new CurvedAnimation( - parent: controller, + parent: controller!, curve: new Interval( 0.100, 0.900, @@ -130,11 +130,11 @@ class FabMenuMiniItemWidget extends StatelessWidget { return new Container( padding: new EdgeInsetsTween( end: const EdgeInsets.only(bottom: 0.0), - begin: EdgeInsets.only(top: deviceHeight / itemCount / 3), + begin: EdgeInsets.only(top: deviceHeight / itemCount! / 3), ) .animate( new CurvedAnimation( - parent: controller, + parent: controller!, curve: new Interval( 0.100, 0.600, @@ -150,7 +150,7 @@ class FabMenuMiniItemWidget extends StatelessWidget { ) .animate( new CurvedAnimation( - parent: controller, + parent: controller!, curve: new Interval( 0.100, 0.600, @@ -182,8 +182,8 @@ class FabMenuMiniItemWidget extends StatelessWidget { margin: new EdgeInsets.symmetric(horizontal: 8.0), child: new ScaleTransition( scale: new CurvedAnimation( - parent: controller, - curve: new Interval(((index + 1) / 10), 1.0, + parent: controller!, + curve: new Interval(((index! + 1) / 10), 1.0, curve: Curves.linear), ), child: _getChip(), @@ -191,8 +191,8 @@ class FabMenuMiniItemWidget extends StatelessWidget { ), new ScaleTransition( scale: new CurvedAnimation( - parent: controller, - curve: new Interval(((index + 1) / 10), 1.0, + parent: controller!, + curve: new Interval(((index! + 1) / 10), 1.0, curve: Curves.linear), ), child: _getFloatingActionButton(), @@ -203,12 +203,12 @@ class FabMenuMiniItemWidget extends StatelessWidget { } } - Widget _getChip() { + Widget? _getChip() { return chipColor != null ? new Chip( backgroundColor: chipColor, label: new Text( - text, + text!, textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, style: @@ -228,8 +228,8 @@ class FabMenuMiniItemWidget extends StatelessWidget { child: icon, heroTag: "$index", onPressed: () { - onPressed(); - hideWidget == null ? null : hideWidget(); + onPressed!(); + hideWidget == null ? null : hideWidget!(); }) : new FloatingActionButton( elevation: elevation, @@ -241,7 +241,7 @@ class FabMenuMiniItemWidget extends StatelessWidget { decoration: new BoxDecoration( shape: BoxShape.circle, image: new DecorationImage( - image: image, + image: image!, fit: BoxFit.cover, ), ), @@ -249,8 +249,8 @@ class FabMenuMiniItemWidget extends StatelessWidget { ), heroTag: "$index", onPressed: () { - onPressed(); - hideWidget == null ? null : hideWidget(); + onPressed!(); + hideWidget == null ? null : hideWidget!(); }); } @@ -263,7 +263,7 @@ class FabMenuMiniItemWidget extends StatelessWidget { children: [ new AnimatedBuilder( builder: _buildAnimation, - animation: controller, + animation: controller!, ), ], ), diff --git a/pubspec.yaml b/pubspec.yaml index 9e326ca..5c63e3b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,16 +1,16 @@ name: flutter_fab_dialer description: Flutter plugin for using a Fab Dialer / Fab Speed Dial to use it as a menu. It uses material design library as the FAB is originated from Android. -version: 0.1.1 +version: 0.2.1 author: Leondev7 homepage: https://github.com/Leondev7/flutter_fab_dialer +environment: + sdk: '>=2.12.0 <3.0.0' + dependencies: flutter: sdk: flutter dev_dependencies: - test: ^1.3.3 - -environment: - sdk: ">=2.0.0 <3.0.0" \ No newline at end of file + test: ^1.16.5