Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can not use iminPrinter.getPrinterStatus() #10

Open
thanapon1998 opened this issue Mar 12, 2024 · 0 comments
Open

I can not use iminPrinter.getPrinterStatus() #10

thanapon1998 opened this issue Mar 12, 2024 · 0 comments

Comments

@thanapon1998
Copy link

My code

import 'package:flutter/material.dart';
import 'package:imin_printer/imin_printer.dart';
import 'package:imin_printer/imin_style.dart';

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

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Print Imin'),
);
}
}

class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});

final String title;

@OverRide
State createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
IminPrinter iminPrinter = IminPrinter();

@OverRide
void initState() {
// TODO: implement initState
super.initState();
initPrint();
}

Future initPrint() async {
// all method from imin printer need to async await
await iminPrinter.initPrinter().then((value) {
print('init ${value.toString()}');
}); // must init the printer first. for more exmaple.. pls refer to example tab.

await iminPrinter.getPrinterStatus().then((value) {
  print(value.toString());
});

}

Future printImin() async {
// await iminPrinter.printQrCode('https://www.imin.sg');

await iminPrinter.printText('print example',
    style: IminTextStyle(wordWrap: true));

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child:
ElevatedButton(onPressed: printImin, child: Text('Print IMIN'))),
);
}
}

Issues

I/flutter (11895): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (11895): │ #0 MethodChannelIminPrinter.getPrinterStatus (package:imin_printer/imin_printer_method_channel.dart:35:12)
I/flutter (11895): │ #1
I/flutter (11895): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (11895): │ 🐛 code -1
I/flutter (11895): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (11895): {code: -1, msg: Failed to initialize the printer!}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant