flutter_net_promoter_score 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

Flutter Net Promoter Score #

A Flutter component that presents Net Promoter Score (NPS) survey.

Features #

  • Show Net Promoter Score survey
  • Get user interactions call backs (such as score changes and feedback input)
  • Get final survery result with Score, Promoter type and feedback text
  • Support flutter themes to customize look and feel
  • Customize all texts with your own textss

Table of contents #

How to use #

Installation #

Add flutter_net_promoter_score to your project dependencies

dependencies:
  flutter_net_promoter_score:

Show the survey #

Import flutter_net_promoter_score

import 'package:flutter_net_promoter_score/flutter_net_promoter_score.dart';

In order to show the survery call the function showNetPromoterScore and provide the required parameters.

Example:

  void _showNPS() {
    showNetPromoterScore(
      context: context,
      texts: NpsSurveyTexts(
        selectScorePageTexts: NpsSelectScorePageTexts(
          surveyQuestionText:
              "How likely are you to recommend flutter_net_promoter_score to a friend or colleague?",
        ),
      ),
      onSurveyCompleted: (result) {
        print("NPS Completed");
        print("Score: ${result.score}");
        print("Feedback: ${result.feedback}");
        print("Promoter Type: ${result.promoterType}");
      },
      onClosePressed: () {
        print("User closed the survery");
      },
      onScoreChanged: (newScore) {
        print("User changed the score to $newScore");
      },
      onFeedbackChanged: (newFeedback) {
        print("User change the feedback to $newFeedback");
      },
      thankYouIcon: Icon(
        Icons.thumb_up,
      ),
      theme: ThemeData.dark()
    );
  }

Customize texts #

You can customize the texts with your own texts by passing the text parameter. The text parameter contains the following members. Change this members to set you own texts.

  • selectScorePageTexts- Controls the first view texts: "Select Score" .
  • feedbackPageTexts - Controls the second view texts: "Feedback".
  • thankYouPageTexts - Controls the last view texts: "Thank You".

Theming #

flutter_net_promoter_score supports Flutter's themes and gets its look and feel by the app's default Theme style. To customize the look and feel with your favorite appearance you can use the theme parameter and change it according to the following parameters:

AttributesTypeDescription
cardColorColorChange Background Color
textTheme.captionTextStyleLabels style
textTheme.subtitle2TextStyleQuestions and titles style
bodyText1.bodyText1TextStyleScore numbers text style
textTheme.buttonTextStyleButtons text style
sliderTheme.thumbColorColorSelected score color
buttonColorColorButtons background color
focusColorColortext field background color
backgroundColorColorScore slider background color
sliderTheme.activeTickMarkColorColorScore slider unselected dots color
iconThemeIconThemeDataClose button icon and default thank you icon IconThemeData
hintColorColorFeedback field hint text color

Change Log #

See Change Log page.

Contribution #

Please file feature requests and bugs at the issue tracker.

Author #

Tomer Shalom

[1.0.0] #

Initial release

  • Show Net Promoter Score survey
  • Get user interactions call backs (such as score changes and feedback input)
  • Get final survery result with Score, Promoter type and feedback text.
  • Support flutter themes to customize look and feel
  • Customize all texts with your own texts.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_net_promoter_score/flutter_net_promoter_score.dart';
import 'package:flutter_net_promoter_score/model/nps_survey_texts.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Net Promoter Score Demo',
      theme: ThemeData.light(),
      darkTheme: ThemeData.dark(),
      home: MyHomePage(title: 'Net Promoter Score Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    Timer.run(() {
      _showNPS();
    });
  }

  void _showNPS() {
    showNetPromoterScore(
      context: context,
      texts: NpsSurveyTexts(
        selectScorePageTexts: NpsSelectScorePageTexts(
          surveyQuestionText:
              "How likely are you to recommend flutter_net_promoter_score to a friend or colleague?",
        ),
      ),
      onSurveyCompleted: (result) {
        print("NPS Completed");
        print("Score: ${result.score}");
        print("Feedback: ${result.feedback}");
        print("Promoter Type: ${result.promoterType}");
      },
      onClosePressed: () {
        print("User closed the survery");
      },
      onScoreChanged: (newScore) {
        print("User changed the score to $newScore");
      },
      onFeedbackChanged: (newFeedback) {
        print("User change the feedback to $newFeedback");
      },
      thankYouIcon: Icon(
        Icons.thumb_up,
      ),
      theme: ThemeData.light()
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FlatButton(
              onPressed: () {
                _showNPS();
              },
              child: Text("Show NPS"),
              color: Colors.grey,
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_net_promoter_score: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_net_promoter_score/flutter_net_promoter_score.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_net_promoter_score that is a package requiring null.

Health suggestions

Format lib/flutter_net_promoter_score.dart.

Run flutter format to format lib/flutter_net_promoter_score.dart.

Format lib/model/net_promoter_score_result.dart.

Run flutter format to format lib/model/net_promoter_score_result.dart.

Format lib/model/nps_survey_page.dart.

Run flutter format to format lib/model/nps_survey_page.dart.

Format lib/model/promoter_type.dart.

Run flutter format to format lib/model/promoter_type.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
flutter_score_slider ^1.0.1 1.0.1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test