Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money. Xiaolai just learned about the custom bottom status bar two days ago, now add the style of fixed protruding middle Item bit, and generate plug-in can not be sent in Pub.

Supplementary style (middle bulge)

There is a kind of middle protrude style for the side dish. The middle protrude only when the total number of items is odd, but not when the number of items is even. By default, other items are normal Nomal style, supporting pictures or ICONS and text color changing effects.

Enum ACEBottomNavigationBarType {/ / normal, ordinary type, select the color and style the same zoom, / / image or icon, the hidden text, support the discoloration zoomout, / / image or icon, and protruding shows, Protruding, protruding, protruding, protruding, protruding, protruding, protruding, protruding, protruding, protruding, protruding, protruding, protrudingCopy the code

Side dishes in the first few types of configuration effect is mainly inNavigationItemWhile the fixed convex bit style is only shown in the middle, so the side dish is ready inACEBottomNavigationBarIs configured in theitemTotal, and then show the middle position protruding. One of the small vegetables steal a lazy, because only in the middle of the show, so in the sonNavigationItemtypeThe type is passing isnomelType, just check whether the middle bit is displayed.

Widget protrudingWid() { Widget proWid; If (widget.items. Length % 2 == 0) {proWid = Container(width: 0.0, height: 0.0); } else { proWid = Positioned.fill( top: -30, child: Container( child: Padding( padding: const EdgeInsets.only(bottom: 10), child: Stack(alignment: alignment. Center, children: <Widget>[SizedBox(height: 60.0, width: 60.0, child: Container( decoration: BoxDecoration( shape: BoxShape.circle, color: widget.protrudingColor != null ? widget.protrudingColor : Colors.white), child: Padding( padding: True, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true } return proWid; } Widget protrudingItemWid(NavigationItemBean item) { Widget itemWidget; if (item.image ! = null) { itemWidget = GestureDetector( child: Image(image: item.image), onTap: () { widget.onTabChangedListener(protrudingIndex); _setSelected(item.key); }); } else { itemWidget = IconButton( highlightColor: Colors.transparent, splashColor: Colors.transparent, alignment: Alignment (0, 0), icon: icon (item icon, size: 40.0, color: item. IconUnSelectedColor,), onPressed: () { widget.onTabChangedListener(protrudingIndex); _setSelected(item.key); }); } return itemWidget; }Copy the code

Publish Pub plugins

There are five types of side dishes, which can basically meet the daily needs of side dishes. Try to generate the first version of plug-ins and publish them to Pub warehouse.

1. Create a plugin

File -> New -> New Flutter Project… -> The Flutter Plugin is implemented in the same way as Android. The function of the Flutter Plugin is implemented in lib, and the basic call is implemented in Example, and then uploaded to Git.

2. Publish Pub warehouse

According to the official website, in fact, it is very convenient, but there are a lot of places to pay attention to, the early preparation of the external environment and Google email account, small dish next details the problems encountered.

Problem 1: Improving information and package size

Yaml contains a Warning that the flutter packages pub publish –dry-run is not complete and the package is larger than 100M. Note that author suggests adding a mailbox and then deleting useless cache files. Run the command again.

Question 2: Pub finished with exit code 1

Flutter packages pub publish Failed to upload the package. Because there is no error reminder, this can worry bad side dish, do not know where to start;

The official website suggests starting from the network environment, but xiaocai network is normal access; After consulted the great god on the net again, the proposal is in homeTurn off the domestic mirror, try again finally succeeded, happiness arises spontaneously ah!


Xiao CAI first attempt to release plug-ins, there are many imperfect places, will try to maintain, there are wrong places, please give more advice.

GitHub source Pub repository

Source: Little Monk A Ce