Skip to content

nstack-io/flutter-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bf246c2 · Jul 22, 2021

History

75 Commits
Mar 9, 2021
Apr 23, 2020
Apr 23, 2020
Jul 22, 2021
Apr 23, 2020
Jul 15, 2021
Jun 6, 2020
Apr 28, 2020
Apr 23, 2020
Apr 23, 2020
Apr 23, 2020
Jun 10, 2020
Apr 26, 2020
Jul 22, 2021
Jul 22, 2021

Repository files navigation

NStack

NStack Flutter

NStack Flutter, provided as a plugin package, is a companion software development kit to the NStack backend.

See NStack documentation for more information.

How to use

Install

To use NStack, you will need your typical build_runner setup.
First, install build_runner and NStack by adding them to your pubspec.yaml file:

dependencies:
  nstack:
    git:
      url: git://github.com/nstack-io/flutter-sdk.git
      ref: v0.1.4

dev_dependencies:
  build_runner:

This installs two packages:

  • build_runner, the tool to run code-generators
  • NStack SDK, which includes a code generator

Run the generator

Create a nstack.json file under /lib that holds your NStack details:

{
  "version": 1,
  "nstack_project_id": "YOUR_PROJECT_ID",
  "nstack_api_key": "YOUR_REST_API_KEY"
}

Now, depending on your use case you have two possibilities to run the generator:

If your package depends on Flutter execute:

foo@bar:~$ flutter pub run build_runner build

Otherwise execute:

foo@bar:~$ pub run build_runner build

A successful execution generates your project tailored nstack.dart file.
See example below on how to use your NStack instance.

Incremental updates

To run a persistent build server that watches nstack.json to automatically trigger rebuilds execute:

foo@bar:~$ flutter pub run build_runner watch --delete-conflicting-outputs

Now increment the "version" number and save (⌘s) to trigger an update.

Example

Import your nstack.dart file and plant your NStackWidget at the root of your application.
Use NStackInitWidget for submitting AppOpen events.

import 'package:flutter/material.dart';
import 'package:nstack_example/nstack.dart';

void main() {
  runApp(NStackWidget(child: MyApp()));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: NStackInitWidget(
        child: Scaffold(
          appBar: AppBar(
            title: Text(context.localization.test.title),
          ),
        ),
      ),
    );
  }
}