fluct
A tool to help develop Flutter application. — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — – | making address: | github.com/rhymelph/fl… | pub address: | pub. Dev/packages/fl… ` — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — –
The installation
This tool does not need to be added to dependencies, we just need to enable it, using the following command:
$ pub global activate fluct
# or
$ flutter pub global activate fluct
Copy the code
use
Fluct currently only two orders create and Gen-Assets
create
Used to create files andwidget
, file name pressDart
Underline the words specified by the file naming rule without specifying them.dart
Suffixes, such as:index_page
gen-assets
Resource file bindings for automatically generating Flutter
fluct create
During the development of Flutter, it is necessary to create files. However, the creation file of AS does not automatically generate relevant content, which makes developers very upset. If you need to manually type the class name, this command can be used in one step.
After the command is executed, the following information is displayed
Help Flutter application create a new file
Usage: fluct create [arguments] <path>
-h, --help Print this usage information.
-t, --type
[custom] Create a new file about custom widget in 'fluct.yaml'Create a file for custom widgets,-aCreate a StatefulWidget file [stless] Create a new file to specify your directive [stful] Create a new file about StatefulWidget in the 'fluct.yaml' file About StatelessWidget Creates the StatelessWidget file-a, --arg create a new file about your custom widget use arg in 'fluct.yaml'Use your in'fluct.yaml'The declared directive Run"fluct help" to see global options.
Copy the code
As you can see, the output of this command is straightforward, so let’s use it briefly.
Simple to use
To create an IndexPage page inherited from StatefulWidget, use the following command:
$ fluct create -t stful ./index_page
Create a new file about StatefulWidget
create class IndexPage
create success
exit 0
Copy the code
After a successful run, we will find the index_page.dart file under the project, which reads:
import 'package:flutter/material.dart';
class IndexPage extends StatefulWidget {
@override
_IndexPageState createState() => _IndexPageState();
}
class _IndexPageState extends State<IndexPage> {
@override
Widget build(BuildContext context) {
returnContainer(); }}Copy the code
Of course, you can also specify which folder, for example, I want to create IndexPage in the./lib/ SRC /page folder, using the following command
$ fluct create -t stful ./lib/src/page/index_page
Copy the code
Custom content file
Yaml tofluct. yaml tofluct. yaml tofluct. yaml tofluct. yaml tofluct. yaml tofluct. yaml tofluct. yaml tofluct tofluct. yaml tofluct tofluct
inh: | import 'package:flutter/material.dart'; class $NAME$ extends InheritedWidget { const $NAME$({ Key key, @required Widget child, }) : assert(child ! = null), super(key: key, child: child); static $NAME$ of(BuildContext context) { return context.dependOnInheritedWidgetOfExactType(aspect: $NAME$) as $NAME$; } @override bool updateShouldNotify($NAME$ old) { return false; }}Copy the code
Here, I declare the inh command, and then run this command to add the inh content to the generated file, we should note the $NAME$placeholder, the string will be replaced by the generated content according to the file NAME, for example: Index_page inserts IndexPage into the $NAME$placeholder. Finally, we run the following command:
$ fluct create -t custom -a inh ./index_inherited
Copy the code
After the operation is successful, the index_Inheritance. dart file is found in the root directory with the corresponding custom content
import 'package:flutter/material.dart';
class IndexInherited extends InheritedWidget {
const IndexInherited({
Key key,
@required Widget child,
}) : assert(child ! =null),
super(key: key, child: child);
static IndexInherited of(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType(aspect: IndexInherited) as IndexInherited;
}
@override
bool updateShouldNotify(IndexInherited old) {
return false; }}Copy the code
(NEW)fluct gen-assets
Yaml file. For example, if I add a.png images to the./assets/images folder, I need to declare the path of the resource file in pubspec.yaml
flutter:
assets:
- assets/images/a.png
Copy the code
Or use folder paths
flutter:
assets:
- assets/images/
Copy the code
This fluct gen assets command helps you to fluct gen assets. Fluct Gen Assets command fluct gen Assets command enables you to fluct gen assets
The following is displayed when operating gen- Assets h
Auto generate assets to dart file
Usage: fluct gen-assets [arguments] <path>
-h, --help Print this usage information.
-a, --assets your asset directory path -- default./assets your asset directory path, -o, --output your output directory path -- default./lib/generated The 'a. art' file path Run"fluct help" to see global options.
Copy the code
Click here to witness your fluct Gen Assets today
a.dart
// fluct gen-assets command generated.
// author: rhyme_lph
// github: https://github.com/rhymelph
/ / version: 1.0.3
class A {
static final String assetsVillageMyMsg = 'assets/village/my_msg.png';
static final String assetsVillageVRepair = 'assets/village/v_repair.png';
static final String assetsVillageVPropertyFee = 'assets/village/v_property_fee.png';
static final String assetsVillageVVoting = 'assets/village/v_voting.png';
static final String assetsVillageIcCompany = 'assets/village/ic_company.png';
static final String assetsVillageIcRightArrow = 'assets/village/ic_right_arrow.png';
static final String assetsVillageVComplain = 'assets/village/v_complain.png';
static final String assetsVillageIcLaw = 'assets/village/ic_law.png';
static final String assetsVillageIcSearch = 'assets/village/ic_search.png';
static final String assetsVillageIvFamilyNorepair = 'assets/village/iv_family_norepair.png';
static final String assetsVillageIcUploadPic = 'assets/village/ic_upload_pic.png';
static final String assetsVillageIvFamilyNocomplaint = 'assets/village/iv_family_nocomplaint.png';
static final String assetsVillageIvFamilyNoad = 'assets/village/iv_family_noad.png';
static final String assetsVillageIcGovernment = 'assets/village/ic_government.png';
static final String assetsVillageVHouse = 'assets/village/v_house.png';
static final String assetsPayPayTypeWx = 'assets/pay/pay_type_wx.png';
static final String assetsPayPayTypeAbc = 'assets/pay/pay_type_abc.jpg';
static final String assetsPayPayTypeAli = 'assets/pay/pay_type_ali.png';
static final String assetsMessageArticle4 = 'assets/message/article_4.jpg';
static final String assetsMessageArticle1 = 'assets/message/article_1.jpg';
static final String assetsMessageArticle3 = 'assets/message/article_3.jpg';
static final String assetsMessageArticle2 = 'assets/message/article_2.jpg';
static final String assetsMessageMReturn = 'assets/message/m_return.png';
static final String assetsMineDefaultAvatar = 'assets/mine/default_avatar.png';
static final String assetsMineMyMsg = 'assets/mine/my_msg.png';
static final String assetsMineHwpushIcToolbarRefresh = 'assets/mine/hwpush_ic_toolbar_refresh.png';
static final String assetsMineArrowRight = 'assets/mine/arrow_right.png';
static final String assetsMineWhiteRight = 'assets/mine/white_right.png';
static final String assetsMineIvCardEmblem = 'assets/mine/iv_card_emblem.png';
static final String assetsMineHomeCenterNormal = 'assets/mine/home_center_normal.png';
static final String assetsMineUserCenterNormal = 'assets/mine/user_center_normal.png';
static final String assetsMineVideoCamera = 'assets/mine/video_camera.png';
static final String assetsMineShare = 'assets/mine/share.png';
static final String assetsMineIconCamera = 'assets/mine/icon_camera.png';
static final String assetsMineIvCardFace = 'assets/mine/iv_card_face.png';
static final String assetsMineMySetting = 'assets/mine/my_setting.png';
static final String assetsMineUmiIdentity = 'assets/mine/umi_identity.png';
static final String assetsMineUmiModfiyPwd = 'assets/mine/umi_modfiy_pwd.png';
static final String assetsMineMyBill = 'assets/mine/my_bill.png';
static final String assetsLoginIcClose = 'assets/login/ic_close.png';
static final String assetsLoginIcLauncher = 'assets/login/ic_launcher.png';
static final String assetsLoginIcLoginBg = 'assets/login/ic_login_bg.png';
static final String assetsLoginIcEyesClose = 'assets/login/ic_eyes_close.png';
static final String assetsLoginIcEyesOpen = 'assets/login/ic_eyes_open.png';
}
Copy the code
Everything is declared, very good ~
Run commands in Flutter
We may fluct create a pub global activate command to activate a flutter pub run fluct create
Finally, I hope you enjoy this tool and follow me to learn more about Flutter/Dart development