Thursday, 17 September 2020

A custom navigation bar with bubble click effect in Flutter

 

custom_navigation_bar

A custom navigation bar with bubble click effect.

This package gives you a cute bubble effect when you click on the navigation bar.

Dribbble:

68747470733a2f2f63646e2e6472696262626c652e636f6d2f75736572732f323131343538342f73637265656e73686f74732f373133343834392f6d656469612f39366534613630303261343736626164376264383039616337316532383639382e676966
Implemented:

screenshot

1--1-

2--1-

3--1-

4--1-

5--1-

6--1-

How to install

Add this to your package's pubspec.yaml file:

dependencies:
  custom_navigation_bar: ^0.3.0
YAML

Documentation

You can customize these attributes in the navigation bar.

ATTRIBUTESTYPEDESCRIPTIONDEFAULT
scaleFactordoublescale factor for the icon scale animation.0.2
elevationdoubleThe z-coordinate of this CustomNavigationBar8.0
itemsListitem data in CustomNavigationBarrequired
selectedColorColor[Color] when [CustomNavigationBarItem] is selected[blueAccent]
unSelectedColorColor[Color] when [CustomNavigationBarItem] is not selected.grey[600]
onTapFunction(int)callback function when item tappednull
currentIndexintcurrent index of navigation bar.0
iconSizedoublesize of icon. also represent the max radius of bubble effect animation.24.0
backgroundColorColorBackground color of [CustomNavigationBar]Colors.white
strokeColorColorstroke colorblueAccent
bubbleCurveCurveanimation curve of bubble effectlinear
scaleCurveCurveanimation curve of scale effectlinear
borderRadiusRadiusborder radius of navigation barRadius.zero
isFloatingboolcontrol if CustomNavigationBar is floatingfalse

And for customize icon in the navigation bar, just put the icons you want in the CustomNavigationBarItem like this.

CustomNavigationBar(
        ...
        items: [
          CustomNavigationBarItem(
            icon: Icons.home,
          ),
          CustomNavigationBarItem(
            icon: Icons.shopping_cart,
          ),
          CustomNavigationBarItem(
            icon: Icons.lightbulb_outline,
          ),
          CustomNavigationBarItem(
            icon: Icons.search,
          ),
          CustomNavigationBarItem(
            icon: Icons.account_circle,
          ),
        ],
        ...
      )
Dart

Attention: If you set isFloating to true, I would recommand you to set extendBody to true in Scaffold for a better performance.

Example

Check example app for more details.

Future Plans

  • [x] Code format
  • [x] Make it more like native navigation bar in Flutter.
  • [x] Better documentation
  • [ ] More customizations!!

GitHub

A custom navigation bar with bubble click effect in Flutter — Read More

Latest commit to the master branch on 9-16-2020
Download as zip

Wednesday, 8 April 2020

DateField in Flutter Made Easy

What you probably did if you already have a DateField in your Flutter project is to create it from scratch! But did you know that you could use this package to simplify your life a lot?

First, as usual, just add it to your pubspec.yaml file.
dependencies:
   date_field: ^0.1.2
   ...

Now after a little pub get you should be able to access the package content!
First, let’s just try to display a simple DateField in our view. There are two important parameters:
  1. onDateSelected which is triggered whenever the user picks a date!
  2. selectedDate which will be the date displayed in the field, if it is null, it will display a placeholder.
So a simple implementation would give us the following:
DateTime selectedData;...Widget buid(...) {
...return DateField(
    onDateSelected: (DateTime value) {
      setState(() {
        selectedData = value;
      });
     },
     selectedDate: selectedData,
  );
And the result should look like:


DateField in FlutterDateField in Flutter

Now that we saw the basis,
If you want your user to pick a date within a specified range, you should make use of the firstDate and lastDate parameters.
Example :
DateTime selectedData;...Widget buid(...) {
...return DateField(
    onDateSelected: (DateTime value) {
      setState(() {
        selectedData = value;
      });
     },
     firstDate: DateTime(2020, 3, 8),
     lastDate: DateTime(2020, 3, 20),
     selectedDate: selectedData,
  );
And now when the user picks a date, the dialog will look like that:

and even more further…
Now let’s see how we can customize this DateField, for that we have three interesting parameters:
  1. decoration: which allows us to completely customize the field decoration.
  2. label: which can be used to rename the field.
  3. dateFormat: which can be used to change the way the date is shown.
Long story short, here is an example of how to combine those three parameters:
DateTime selectedData;...Widget buid(...) {
...return DateField(
    onDateSelected: (DateTime value) {
      setState(() {
        selectedData = value;
      });
     },
     decoration: InputDecoration(
       border: OutlineInputBorder()
     ),
     label: 'My date field',
     dateFormat: DateFormat.yMd(),
     selectedDate: selectedData,
  );
And the result is a field in a different style:

DateField in Flutter