Zhuge Io Mobile Statistics Support Flutter Framework

Flutter集成文档

诸葛io移动统计支持Flutter框架,以下为集成方法。

1.在项目中添加安装插件

在Flutter项目的pubspec.yaml文件中添加zhugeio依赖包

  dependencies:
   # zhugeio flutter plugin 
   zhuge: ^1.0.2

执行flutter packages get 命令安装插件

  flutter packages get  

请参考:Flutter官网文档

2.Android端

2.1 添加诸葛分析所需相关权限:

<!--需要网络权限-->
<uses-permission  
  android:name="android.permission.INTERNET"/>
<!--需要获取网络状态-->
<uses-permission  
  android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission  
  android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--获取设备唯一标识-->
<uses-permission  
  android:name="android.permission.READ_PHONE_STATE"/>

2.2 添加项目依赖

dependencies {
     implementation "io.github.zhugefe:zhugeio-analytics:latest.integration"
}

2.3 初始化SDK

通过代码配置AppKey及Channel并启动;

若你希望通过代码传递appKey及渠道信息,请使用ZhugeParam实体类来定义信息,然后使用该参数初始化SDK:

import com.zhuge.analysis.stat.ZhugeParam;
import com.zhuge.analysis.stat.ZhugeSDK;

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
    ZhugeParam param = new ZhugeParam.Builder().appKey("appkey")
            .appChannel("channel")
            .build();
    ZhugeSDK.getInstance().initWithParam(getApplicationContext(), param);
  }
}

若是私有部署的用户,需要更改数据上传地址,请将上述onCreate()里的代码更改为:

@Override
      public void onCreate(){
         Super.onCreate();
         ...
         //设置上传地址,普通用户请勿更改。必须在调用init之前设置
         ZhugeSDK.getInstance().setUploadURL("URL","backupUrl");
         //ZhugeSDK初始化
         ZhugeSDK.getInstance().init(this,"your AppKey","youAppChannel");   
         ...

      }

3.iOS端

3.1 项目目录下执行pod install,依赖原始的SDK

cd ios
pod install

3.2 用应用的Appkey启动诸葛io SDK

    #import "Zhuge.h"

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[Zhuge sharedInstance] startWithAppKey:@"Your AppKey" launchOptions:launchOptions];
}

若是私有部署的用户,需要更改数据上传地址,请将上述代码更改为:

    #import "Zhuge.h"

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        //设置上传地址,一般用户无需更改
        [[Zhuge sharedInstance] setUploadURL:@"URL" andBackupUrl:@"BackUpURL"];
        [[Zhuge sharedInstance] startWithAppKey:@"Your AppKey" launchOptions:launchOptions];
    }

如果你需要修改SDK的默认设置,如设置版本渠道时,一定要在startWithAppKey前执行;代码如下:

 Zhuge *zhuge = [Zhuge sharedInstance];

    // 实时调试开关
    // 设置为YES,可在诸葛io的「实时调试」页面实时观察事件数据上传
    // 建议仅在需要时打开,调试完成后,请及时关闭
    [zhuge.config setDebug : NO];

    // 自定义应用版本
    [zhuge.config setAppVersion:@"0.9-beta"]; // 默认是info.plist中CFBundleShortVersionString值

    // 自定义渠道
    [zhuge.config setChannel:@"My App Store"]; // 默认是@"App Store"

    // 开启行为追踪
    [zhuge startWithAppKey:@"Your AppKey" launchOptions:launchOptions];

4.Flutter中使用插件

在具体dart文件中导入zhugeio.dart

   import 'package:zhugeio/zhugeio.dart';

4.1 记录用户行为

在需要记录用户行为的部分,调用如下方法:

   Zhugeio.track('事件名称',{'属性1':'值1','属性2':'值2'});

**注意:**在添加事件属性时,需注意事件属性类型。如果事件属性类型为「数值型属性」,需要上传数据时修改数据类型为「数值型」,并且在诸葛io后台埋点管理中修改为「数值型」。

4.2 绑定用户信息

为了保持对用户的跟踪,你需要为他们记录一个识别码,可以使用手机号、email等唯一值来作为用户的识别码。另外,也可以在跟踪用户的时候, 记录用户更多的属性信息,便于你更了解你的用户:

   Zhugeio.identify('用户ID',{'用户属性':'用户值'})

4.3 统计事件时长

使用startTrack()开始事件

   Zhugeio.startTrack('事件名称');

使用endTrack()来结束具有相同事件名称的事件

   Zhugeio.endTrack('事件名称',{'属性1':'值1'});

startTrack()endTrack()需成对出现,单独使用没有效果。

4.4 开启实时调试

   Zhugeio.openDebug();

4.5 采集收入数据

记录收入数据采集,需调用trackRevenue函数,自动记录收入事件以及事件属性;price(商品价格)、productID(商品ID)、productQuantity(商品数量)、revenueType(收入类型)为收入事件内置属性,必传项。

具体使用方法如下:

Map product = {"price":229,  
               "productQuantity":2,
               "productID":"小米NFC手环",
               "revenueType":"手环"};
Zhugeio.trackRevenue(product); 

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add zhuge

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  zhuge: ^1.0.5

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:zhuge/zhuge.dart'; 

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:zhuge/zhuge.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  late TextEditingController userNameTF;
  late TextEditingController userKeyTF;
  late TextEditingController userValueTF;

  late TextEditingController eventTF;
  late TextEditingController eventKeyTF;
  late TextEditingController eventValueTF;
  late TextEditingController eventKeyTF2;
  late TextEditingController eventValueTF2;

  late TextEditingController priceTF;
  late TextEditingController productIdTF;
  late TextEditingController productQuantityTF;
  late TextEditingController typeTF;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await Zhuge.platformVersion ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {

    userNameTF = new TextEditingController();
    userKeyTF = new TextEditingController();
    userValueTF = new TextEditingController();

    eventTF = new TextEditingController();
    eventKeyTF = new TextEditingController();
    eventValueTF = new TextEditingController();
    eventKeyTF2 = new TextEditingController();
    eventValueTF2 = new TextEditingController();

    priceTF = new TextEditingController();
    productIdTF = new TextEditingController();
    productQuantityTF = new TextEditingController();
    typeTF = new TextEditingController();

    _buildButton(int tag, String title) {

      return new Container (
        margin: EdgeInsets.only(top: 10.0, left: 15.0),
        height: 30.0,
        width: 150.0,
        child: new MaterialButton(
          color: Colors.blue,
          textColor: Colors.white,
          child: new Text(title),
          onPressed: () {
            clickButton(tag);
          },
        ),
      );
    }

    _buildTF(String hintText, TextEditingController _tf) {
      return new Container(
        margin: EdgeInsets.only(top: 5.0,left: 15.0,right: 15),
        height: 39.0,
//        SingleChildScrollView
        child: new TextField(
          controller: _tf,
          decoration: InputDecoration(
            contentPadding: EdgeInsets.all(5.0),
            border: OutlineInputBorder (
              borderRadius: BorderRadius.circular(4.0),
            ),
            fillColor: Colors.white70,
            filled: true,
            hintText: hintText,
          ),
        ),
      );
    }

    _buildTitle(String title) {
      return new Container(
        margin: EdgeInsets.only(top: 20.0,left: 15.0,right: 15.0),
        child: Text(
          title,
          style: TextStyle(fontWeight: FontWeight.bold),
        ),
      );
    }

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin Zhuge app'),
        ),
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              //用户追踪
              _buildTitle("UserID: "),
              _buildTF("用户名", userNameTF),

              Row(
                children: <Widget>[
                  new Expanded(child: _buildTF("key", userKeyTF)),
                  new Expanded(child: _buildTF("value", userValueTF)),
                ],
              ),

              _buildButton(0, "追踪用户"),

              //自定义事件追踪
              _buildTitle("自定义事件:"),
              _buildTF("事件名称", eventTF),

              Row(
                children: <Widget>[
                  new Expanded(
                    child: _buildTF("Key1",eventKeyTF),
                  ),
                  new Expanded(
                    child: _buildTF("Value1",eventValueTF),
                  ),
                ],
              ),
              Row(
                children: <Widget>[
                  new Expanded(
                    child: _buildTF("Key2",eventKeyTF2),
                  ),
                  new Expanded(
                    child: _buildTF("Value2", eventValueTF2),
                  ),
                ],
              ),
              _buildButton(1,"追踪事件"),

              //收入事件统计
              _buildTitle("收入事件:"),
              Row(
                children: <Widget>[
                  new Expanded(
                    child: _buildTF("Price",priceTF),
                  ),
                  new Expanded(
                    child: _buildTF("ProductQuantity",productQuantityTF),
                  ),
                ],
              ),

              Row(
                children: <Widget>[
                  new Expanded(
                    child: _buildTF("ProductId",productIdTF),
                  ),
                  new Expanded(
                    child: _buildTF("Type",typeTF),
                  ),
                ],
              ),
              _buildButton(2,"追踪收入"),
            ],
          ),
        )
      ),
    );
  }


  clickButton(int tag) {
    if(tag == 0) {
//      Zhugeio.identify("zhangsan", {"age":18});
      Zhuge.identify(userNameTF.text, getUserInfo());
    } else if (tag == 1) {
      Zhuge.track(eventTF.text, getDefaultEventsInfo());
    } else if (tag == 2) {
      Zhuge.trackRevenue(getRevenueEventsInfo());
    }
  }

  Map getUserInfo() {
    Map userPro;
    userPro = {userNameTF.text:userValueTF.text};
    print( userNameTF.text + "== $userPro" );
    return userPro;
  }

  Map getDefaultEventsInfo() {
    Map defaultPro;
    defaultPro = {eventKeyTF.text:eventValueTF.text, eventKeyTF2.text:eventValueTF2.text};
    print( eventTF.text + "== $defaultPro" );
    return defaultPro;
  }

  Map getRevenueEventsInfo() {
    Map revenuePro;
//    revenuePro.put("price",100.12);  //数值型属性不要带引号
//    revenuePro.put("productID","小米NFC手环");
//    revenuePro.put("productQuantity",2); //数值型属性不要带引号
//    revenuePro.put("revenueType","手环");
    revenuePro = {"price":priceTF.text,
      "productQuantity":productQuantityTF.text,
      "productID":productIdTF.text,
      "revenueType":typeTF.text};
    print("RevenuePro == $revenuePro" );
    return revenuePro;
  }
} 

Download Details:

Author: 

Source Code: https://pub.dev/packages/zhuge

#flutter #android 

What is GEEK

Buddha Community

Zhuge Io Mobile Statistics Support Flutter Framework

Google's Flutter 1.20 stable announced with new features - Navoki

Flutter Google cross-platform UI framework has released a new version 1.20 stable.

Flutter is Google’s UI framework to make apps for Android, iOS, Web, Windows, Mac, Linux, and Fuchsia OS. Since the last 2 years, the flutter Framework has already achieved popularity among mobile developers to develop Android and iOS apps. In the last few releases, Flutter also added the support of making web applications and desktop applications.

Last month they introduced the support of the Linux desktop app that can be distributed through Canonical Snap Store(Snapcraft), this enables the developers to publish there Linux desktop app for their users and publish on Snap Store.  If you want to learn how to Publish Flutter Desktop app in Snap Store that here is the tutorial.

Flutter 1.20 Framework is built on Google’s made Dart programming language that is a cross-platform language providing native performance, new UI widgets, and other more features for the developer usage.

Here are the few key points of this release:

Performance improvements for Flutter and Dart

In this release, they have got multiple performance improvements in the Dart language itself. A new improvement is to reduce the app size in the release versions of the app. Another performance improvement is to reduce junk in the display of app animation by using the warm-up phase.

sksl_warm-up

If your app is junk information during the first run then the Skia Shading Language shader provides for pre-compilation as part of your app’s build. This can speed it up by more than 2x.

Added a better support of mouse cursors for web and desktop flutter app,. Now many widgets will show cursor on top of them or you can specify the type of supported cursor you want.

Autofill for mobile text fields

Autofill was already supported in native applications now its been added to the Flutter SDK. Now prefilled information stored by your OS can be used for autofill in the application. This feature will be available soon on the flutter web.

flutter_autofill

A new widget for interaction

InteractiveViewer is a new widget design for common interactions in your app like pan, zoom drag and drop for resizing the widget. Informations on this you can check more on this API documentation where you can try this widget on the DartPad. In this release, drag-drop has more features added like you can know precisely where the drop happened and get the position.

Updated Material Slider, RangeSlider, TimePicker, and DatePicker

In this new release, there are many pre-existing widgets that were updated to match the latest material guidelines, these updates include better interaction with Slider and RangeSliderDatePicker with support for date range and time picker with the new style.

flutter_DatePicker

New pubspec.yaml format

Other than these widget updates there is some update within the project also like in pubspec.yaml file format. If you are a flutter plugin publisher then your old pubspec.yaml  is no longer supported to publish a plugin as the older format does not specify for which platform plugin you are making. All existing plugin will continue to work with flutter apps but you should make a plugin update as soon as possible.

Preview of embedded Dart DevTools in Visual Studio Code

Visual Studio code flutter extension got an update in this release. You get a preview of new features where you can analyze that Dev tools in your coding workspace. Enable this feature in your vs code by _dart.previewEmbeddedDevTools_setting. Dart DevTools menu you can choose your favorite page embed on your code workspace.

Network tracking

The updated the Dev tools comes with the network page that enables network profiling. You can track the timings and other information like status and content type of your** network calls** within your app. You can also monitor gRPC traffic.

Generate type-safe platform channels for platform interop

Pigeon is a command-line tool that will generate types of safe platform channels without adding additional dependencies. With this instead of manually matching method strings on platform channel and serializing arguments, you can invoke native class and pass nonprimitive data objects by directly calling the Dartmethod.

There is still a long list of updates in the new version of Flutter 1.2 that we cannot cover in this blog. You can get more details you can visit the official site to know more. Also, you can subscribe to the Navoki newsletter to get updates on these features and upcoming new updates and lessons. In upcoming new versions, we might see more new features and improvements.

You can get more free Flutter tutorials you can follow these courses:

#dart #developers #flutter #app developed #dart devtools in visual studio code #firebase local emulator suite in flutter #flutter autofill #flutter date picker #flutter desktop linux app build and publish on snapcraft store #flutter pigeon #flutter range slider #flutter slider #flutter time picker #flutter tutorial #flutter widget #google flutter #linux #navoki #pubspec format #setup flutter desktop on windows

Terry  Tremblay

Terry Tremblay

1598396940

What is Flutter and why you should learn it?

Flutter is an open-source UI toolkit for mobile developers, so they can use it to build native-looking** Android and iOS** applications from the same code base for both platforms. Flutter is also working to make Flutter apps for Web, PWA (progressive Web-App) and Desktop platform (Windows,macOS,Linux).

flutter-mobile-desktop-web-embedded_min

Flutter was officially released in December 2018. Since then, it has gone a much stronger flutter community.

There has been much increase in flutter developers, flutter packages, youtube tutorials, blogs, flutter examples apps, official and private events, and more. Flutter is now on top software repos based and trending on GitHub.

Flutter meaning?

What is Flutter? this question comes to many new developer’s mind.

humming_bird_dart_flutter

Flutter means flying wings quickly, and lightly but obviously, this doesn’t apply in our SDK.

So Flutter was one of the companies that were acquired by **Google **for around $40 million. That company was based on providing gesture detection and recognition from a standard webcam. But later when the Flutter was going to release in alpha version for developer it’s name was Sky, but since Google already owned Flutter name, so they rename it to Flutter.

Where Flutter is used?

Flutter is used in many startup companies nowadays, and even some MNCs are also adopting Flutter as a mobile development framework. Many top famous companies are using their apps in Flutter. Some of them here are

Dream11

Dream11

NuBank

NuBank

Reflectly app

Reflectly app

Abbey Road Studios

Abbey Road Studios

and many more other apps. Mobile development companies also adopted Flutter as a service for their clients. Even I was one of them who developed flutter apps as a freelancer and later as an IT company for mobile apps.

Flutter as a service

#dart #flutter #uncategorized #flutter framework #flutter jobs #flutter language #flutter meaning #flutter meaning in hindi #google flutter #how does flutter work #what is flutter

Top Mobile App Development Frameworks in 2021

Do you need a high-quality and reliable framework to optimize the process? AppClues Infotech has created a list of top mobile app development frameworks to consider working with in the year 2021.

For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910

#top mobile app development frameworks #top mobile app frameworks in 2021 #best mobile app development frameworks #best mobile app development frameworks #mobile development framework

Brain  Crist

Brain Crist

1602147600

Flutter App Development Trends 2020

As the new decade dawns upon us, a slew of technologies has been making a lot of noise to grab the developers’ attention. While native app development is going strong, the trade winds are now blowing towards going cross-platform.

Adobe PhoneGap, React Native, Xamarin and Ionic are all leaving no stone unturned to be the undefeated champion of cross-platform development. Still, Google’s Flutter is all set to take them all on at once.

There are a tonne of resources available online to learn about Flutter, and you can start with this step by step flutter guide.

With reduced code development time, increased time-to-market speed, near-native performance, and a bevy of advantages under its hood, Flutter is set to dominate the market this decade.

Before we take a look at trends making the Flutter race ahead in 2020, let us do a quick recap of what Flutter is, for those who have been living under a rock.

#flutter #flutter-for-mobile-app #flutter-app-development #mobile-app-development #flutter-trends #software-development #advantages-of-flutter-mobile #pros-and-cons-of-flutter

Punith Raaj

1644991598

The Ultimate Guide To Tik Tok Clone App With Firebase - Ep 2

The Ultimate Guide To Tik Tok Clone App With Firebase - Ep 2
In this video, I'm going to show you how to make a Cool Tik Tok App a new Instagram using Flutter,firebase and visual studio code.

In this tutorial, you will learn how to Upload a Profile Pic to Firestore Data Storage.

🚀 Nice, clean and modern TikTok Clone #App #UI made in #Flutter⚠️

Starter Project : https://github.com/Punithraaj/Flutter_Tik_Tok_Clone_App/tree/Episode1

► Timestamps 
0:00 Intro 0:20 
Upload Profile Screen 
16:35 Image Picker
20:06 Image Cropper 
24:25 Firestore Data Storage Configuration.

⚠️ IMPORTANT: If you want to learn, I strongly advise you to watch the video at a slow speed and try to follow the code and understand what is done, without having to copy the code, and then download it from GitHub.

► Social Media 
GitHub: https://github.com/Punithraaj/Flutter_Tik_Tok_Clone_App.git
LinkedIn: https://www.linkedin.com/in/roaring-r...
Twitter: https://twitter.com/roaringraaj
Facebook: https://www.facebook.com/flutterdartacademy

► Previous Episode : https://youtu.be/QnL3fr-XpC4
► Playlist: https://youtube.com/playlist?list=PL6vcAuTKAaYe_9KQRsxTsFFSx78g1OluK

I hope you liked it, and don't forget to like,comment, subscribe, share this video with your friends, and star the repository on GitHub!
⭐️ Thanks for watching the video and for more updates don't forget to click on the notification. 
⭐️Please comment your suggestion for my improvement. 
⭐️Remember to like, subscribe, share this video, and star the repo on Github :)

Hope you enjoyed this video!
If you loved it, you can Buy me a coffee : https://www.buymeacoffee.com/roaringraaj

LIKE & SHARE & ACTIVATE THE BELL Thanks For Watching :-)
 
https://youtu.be/F_GgZVD4sDk

#flutter tutorial - tiktok clone with firebase #flutter challenge @tiktokclone #fluttertutorial firebase #flutter firebase #flutter pageview #morioh #flutter