mobiprint3 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

mobiprint3 #

This is a simple unofficial plugin to enable basic printing functionality on the mobiwire mobiprint3 device

Feel free to make contributions to the package.

Getting Started #

In your files #

import 'package:mobiprint3/mobiprint3.dart';

The responses returned are in the format Map<String,dynamic>

sample response

{ "success" : true, "message" : "1" }

To print basic text #

print(String txt);

e.g

Map<String,dynamic> printResponse = await Mobiprint3.print('Hello From flutter\n\n');

To print an image/bitmap #

custom(String text, Integer size);

e.g

Map<String,dynamic> printResponse = await Mobiprint3.custom('Headers',2);

size 1 to 3

To print an image/bitmap #

Not Yet functional

printImage(String image_src )

e.g

not functioning -- pending implementation

To check if paper is loaded (or if is in printer mode) #

checkPaper(); e.g

Map<String,dynamic> printResponse = await Mobiprint3.checkPaper();

To print a space #

space(); e.g

Map<String,dynamic> printResponse = await Mobiprint3.space();

End the printing session [print two terminating lines] #

end(); e.g

Map<String,dynamic> printResponse = await Mobiprint3.end();

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

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

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

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

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

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


  final ThemeData _themeData = new ThemeData(
    brightness: Brightness.light,
    primarySwatch: Colors.blueGrey,
    accentColor: Colors.greenAccent,
    buttonColor: Colors.green,
  );

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    dynamic rsp;
    dynamic rsp2;
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      rsp = await Mobiprint3.print('This is a really simplistic implementation of the mobiprint3 plugin for flutter\n\nOn spotting issues please contribute.');
      rsp2 = await Mobiprint3.custom("ianmin2", 2);
      await Mobiprint3.end();
      // print(rsp);
      print(rsp2);
      platformVersion = 'Flutter@ianmin2';
      // platformVersion = rsp['message'];
    } 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) {
    return MaterialApp(
      // localizationsDelegates: [
      //   GlobalMaterialLocalizations.delegate,
      //   GlobalWidgetsLocalizations.delegate,
      // ],
      // supportedLocales: [
      //     const Locale('en', 'US'),
      // ],
      theme: _themeData,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Mobiprint3 by @ianmin2'),
        ),
        body: ListView(
          padding: EdgeInsets.all(10),
          children: <Widget>[
            RaisedButton(
              child: Text("Print"),
              onPressed: () async {
                final Map<String,dynamic> rsp = await Mobiprint3.print("I am sample text\n");
                print(rsp);
              },
            ),
            SizedBox(height: 6),
            RaisedButton(
              child: Text("Space"),
              onPressed: () async {
                final Map<String,dynamic> rsp = await Mobiprint3.space();
                print(rsp);
              },
            ),
            SizedBox(height: 6),
            RaisedButton(
              child: Text("Custom, 2"),
              onPressed: () async {
                final Map<String,dynamic> rsp = await Mobiprint3.custom("@ianmin2\n\n\n",2);
                print(rsp);
              },
            ),
            SizedBox(height: 6),
            RaisedButton(
              child: Text("Custom, 3"),
              onPressed: () async {
                final Map<String,dynamic> rsp = await Mobiprint3.custom("@ianmin2\n\n\n",3);
                print(rsp);
              },
            ),
            SizedBox(height: 6),
            // RaisedButton(
            //   child: Text("Check Paper"),
            //   onPressed: () async {
            //     Map<String,dynamic>  resp = await Mobiprint3.paper();
            //     print(resp);
            //      return showDialog<void>(
            //        context: context,
            //        barrierDismissible: false,
            //         builder: (BuildContext context) => AlertDialog(
            //           title: Text((resp['success'] == true) ? "GOOD TO GO" : "OOPS!"),
            //           content: Text((resp['success'] == true) ? "Paper is loaded": "No paper is loaded for printing"),
            //           actions: <Widget>[
            //             RaisedButton(
            //               child: Text("CONTINUE"),
            //               onPressed: ()
            //               {
            //                 Navigator.of(context).pop();
            //               },)
            //           ],
            //         )
            //       );
                
            //   },
            // ),
            // SizedBox(height: 6),
          ],
        )
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  mobiprint3: ^1.0.2

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

We analyzed this package on Apr 1, 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 issues and suggestions

Document public APIs. (-1 points)

10 out of 10 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field http://ian.bixbyte.io was unreachable.

Package is getting outdated. (-16.99 points)

The package was last published 61 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.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