aidcore_plugin 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

aidcore_plugin #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:aidcore_plugin/aidcore_plugin.dart';
import 'package:aidcore_plugin_example/toast.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  BlinkingToast toast = new BlinkingToast();
  final navigatorKey = GlobalKey<NavigatorState>();
  GlobalKey _globalKey = new GlobalKey();

  bool inside = false;
  Uint8List imageInMemory;
  Uint8List image;
  
  TextEditingController _printerName = new TextEditingController();
  TextEditingController _messagePrint = new TextEditingController();

  @override
  void initState() {
    super.initState();
    _printerName.text = "Virtual Bluetooth Printer";
    _messagePrint.text = "Example print from android to printer bluetooth - 1";
  }

  Future<Uint8List> _capturePng() async {
    try {
      print('inside');
      inside = true;
      RenderRepaintBoundary boundary =
          _globalKey.currentContext.findRenderObject();
      ui.Image image = await boundary.toImage(pixelRatio: 3.0);
      // ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
      ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
      Uint8List pngBytes = byteData.buffer.asUint8List();
     String bs64 = base64Encode(pngBytes);
     print(pngBytes);
     print(bs64);
      print('png done');
      setState(() {
        imageInMemory = pngBytes;
        inside = false;
      });
      return pngBytes;
    } catch (e) {
      print(e);
    }
  }

  void examplePrint() async{
    await(AidcorePlugin.init(printerName:_printerName.text));
    await(AidcorePlugin.setAlign(align:"center"));
    await(AidcorePlugin.setBold(bold:true));
    await(AidcorePlugin.printText(text:"GWK Cultural Park"));
    await(AidcorePlugin.setBold(bold:false));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Selamat Datang / Welcome"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"www.gwkbali.com"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"------------------------------"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Order Number : 1234567890"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Pos ID : POSID_001"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Cashier : Sempak Superman"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Printed : 19 Masehi Tahun 200 Cahaya"));
    await(AidcorePlugin.addNewLines(count:2));
    await(AidcorePlugin.printText(text:"------------------------------"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"2X  ABC170001 [P] ADULT FORG  250,0000"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"------------------------------"));
    await(AidcorePlugin.addNewLines(count:2));
    await(AidcorePlugin.printText(text:"Total Item    1   Total Qty   2"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Sub Total     (Rp.)       250,0000"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Total         (Rp.)       250,0000"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Payment       (Rp.)       300,0000"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Change        (Rp.)       50,0000"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"------------------------------"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"###### Payment #####"));
    await(AidcorePlugin.addNewLines(count:2));
    await(AidcorePlugin.printText(text:"Payment Type    : Single Payment"));
    await(AidcorePlugin.addNewLines(count:1));
    await(AidcorePlugin.printText(text:"Payment Method  : Cash"));
    await(AidcorePlugin.addNewLines(count:3));
    await(AidcorePlugin.printText(text:"DISINI PAKE BARCODE"));
    await(AidcorePlugin.addNewLines(count:3));
    await(AidcorePlugin.printText(text:"------------------------------"));
    await(AidcorePlugin.finish());
  }

  void webPrint() async {
    return await(AidcorePlugin.pdfView(_printerName.text));
  }

  void imagePrint() async {
    await(AidcorePlugin.init(printerName:_printerName.text));
    await(AidcorePlugin.printImage(imgBytes:imageInMemory));
    await(AidcorePlugin.finish());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      home: new RepaintBoundary(
        key: _globalKey,
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin Example'),
          ),
          body: new Container(
            margin: EdgeInsets.all(5.0),
            child: new ListView(
              children: <Widget>[
                new TextField(
                  controller: _printerName,
                ),
                new TextField(
                  controller: _messagePrint,
                ),
                new RaisedButton(
                  child: new Text('EXAMPLE PRINT'),
                  onPressed: () => examplePrint()
                ),
                new RaisedButton(
                  color: Colors.blue,
                  child: new Text('WEB PRINT PDF', style: TextStyle(color:Colors.white),),
                  onPressed: () => webPrint(),
                ),
                 new RaisedButton(
                  color: Colors.yellow,
                  child: new Text('PRINT CAPTURE', style: TextStyle(color:Colors.black),),
                  onPressed: () => imagePrint(),
                ),
                new RaisedButton(
                  color: Colors.red,
                  child: Text('CAPTURE IMAGE', style: TextStyle(color:Colors.white),),
                  onPressed: _capturePng,
                ),
                inside ? CircularProgressIndicator()
                :
                imageInMemory != null
                    ? Container(
                        child: Image.memory(imageInMemory),
                        margin: EdgeInsets.all(10))
                    : Container(),
              ],
            ),
          )
        ),
      )
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  aidcore_plugin: ^0.0.1

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:aidcore_plugin/aidcore_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/aidcore_plugin.dart. (-0.50 points)

Analysis of lib/aidcore_plugin.dart reported 1 hint:

line 6 col 8: Unused import: 'dart:io'.

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test