Skip to content

Commit

Permalink
v 0.3.0: Added Null-Safety
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Sep 21, 2021
1 parent 6990134 commit 75bd25c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
pubspec.lock
32 changes: 19 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
## [0.3.0]

- Null-Safety

## [0.2.8]
* Bump esc_pos_utils

- Bump esc_pos_utils

## [0.2.7]
* Updated flutter_bluetooth_basic

- Updated flutter_bluetooth_basic

## [0.2.6]
* Updated flutter_bluetooth_basic

- Updated flutter_bluetooth_basic

## [0.2.5]
* Split data into chunks

- Split data into chunks

## [0.2.4]
* `startScan` timeout bug fixed.
* Updated `esc_pos_utils` package version to `0.3.4`.

- `startScan` timeout bug fixed.
- Updated `esc_pos_utils` package version to `0.3.4`.

## [0.2.3]
* Updated `esc_pos_utils` package version to `0.3.3`.

- Updated `esc_pos_utils` package version to `0.3.3`.

## [0.2.2]
* Updated `esc_pos_utils` package version to `0.3.2`.

- Updated `esc_pos_utils` package version to `0.3.2`.

## [0.2.1]
* Updated `esc_pos_utils` package version to `0.3.1` (Open Cash Drawer).

- Updated `esc_pos_utils` package version to `0.3.1` (Open Cash Drawer).

## [0.2.0]
* Updated `esc_pos_utils` package version to `0.3.0` (Image and Barcode alignment).

- Updated `esc_pos_utils` package version to `0.3.0` (Image and Barcode alignment).

## [0.1.1]
* Updated `esc_pos_utils`, `flutter_bluetooth_basic` package versions

- Updated `esc_pos_utils`, `flutter_bluetooth_basic` package versions

## [0.1.0]

## [0.1.0]
* Android and iOS Bluetooth printing support
- Android and iOS Bluetooth printing support
10 changes: 5 additions & 5 deletions example/blue/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MyApp extends StatelessWidget {
}

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

@override
Expand Down Expand Up @@ -68,7 +68,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Print image
final ByteData data = await rootBundle.load('assets/rabbit_black.jpg');
final Uint8List bytes = data.buffer.asUint8List();
final Image image = decodeImage(bytes);
final Image? image = decodeImage(bytes);
// ticket.image(image);

ticket.text('GROCERYLY',
Expand Down Expand Up @@ -254,7 +254,7 @@ class _MyHomePageState extends State<MyHomePage> {
// Print image
final ByteData data = await rootBundle.load('assets/logo.png');
final Uint8List bytes = data.buffer.asUint8List();
final Image image = decodeImage(bytes);
final Image image = decodeImage(bytes)!;
ticket.image(image);
// Print image using alternative commands
// ticket.imageRaster(image);
Expand Down Expand Up @@ -321,7 +321,7 @@ class _MyHomePageState extends State<MyHomePage> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(_devices[index].name ?? ''),
Text(_devices[index].address),
Text(_devices[index].address!),
Text(
'Click to print a test receipt',
style: TextStyle(color: Colors.grey[700]),
Expand All @@ -341,7 +341,7 @@ class _MyHomePageState extends State<MyHomePage> {
stream: printerManager.isScanningStream,
initialData: false,
builder: (c, snapshot) {
if (snapshot.data) {
if (snapshot.data!) {
return FloatingActionButton(
child: Icon(Icons.stop),
onPressed: _stopScanDevices,
Expand Down
4 changes: 2 additions & 2 deletions example/blue/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A new Flutter project.
version: 1.0.0+1

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
Expand All @@ -15,7 +15,7 @@ dependencies:
path: ../../
esc_pos_utils: ^0.3.6
# esc_pos_utils:
# path: ../../../esc_pos_utils
# path: ../../../esc_pos_utils
charset_converter: ^1.0.3
intl: ^0.16.1
qr_flutter: ^3.2.0
Expand Down
22 changes: 11 additions & 11 deletions lib/src/printer_bluetooth_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ class PrinterBluetooth {
PrinterBluetooth(this._device);
final BluetoothDevice _device;

String get name => _device.name;
String get address => _device.address;
int get type => _device.type;
String? get name => _device.name;
String? get address => _device.address;
int? get type => _device.type;
}

/// Printer Bluetooth Manager
class PrinterBluetoothManager {
final BluetoothManager _bluetoothManager = BluetoothManager.instance;
bool _isPrinting = false;
bool _isConnected = false;
StreamSubscription _scanResultsSubscription;
StreamSubscription _isScanningSubscription;
PrinterBluetooth _selectedPrinter;
StreamSubscription? _scanResultsSubscription;
StreamSubscription? _isScanningSubscription;
PrinterBluetooth? _selectedPrinter;

final BehaviorSubject<bool> _isScanning = BehaviorSubject.seeded(false);
Stream<bool> get isScanningStream => _isScanning.stream;
Expand All @@ -55,9 +55,9 @@ class PrinterBluetoothManager {
_isScanningSubscription =
_bluetoothManager.isScanning.listen((isScanningCurrent) async {
// If isScanning value changed (scan just stopped)
if (_isScanning.value && !isScanningCurrent) {
_scanResultsSubscription.cancel();
_isScanningSubscription.cancel();
if (_isScanning.value! && !isScanningCurrent) {
_scanResultsSubscription!.cancel();
_isScanningSubscription!.cancel();
}
_isScanning.add(isScanningCurrent);
});
Expand All @@ -81,7 +81,7 @@ class PrinterBluetoothManager {
const int timeout = 5;
if (_selectedPrinter == null) {
return Future<PosPrintResult>.value(PosPrintResult.printerNotSelected);
} else if (_isScanning.value) {
} else if (_isScanning.value!) {
return Future<PosPrintResult>.value(PosPrintResult.scanInProgress);
} else if (_isPrinting) {
return Future<PosPrintResult>.value(PosPrintResult.printInProgress);
Expand All @@ -94,7 +94,7 @@ class PrinterBluetoothManager {
await _bluetoothManager.stopScan();

// Connect
await _bluetoothManager.connect(_selectedPrinter._device);
await _bluetoothManager.connect(_selectedPrinter!._device);

// Subscribe to the events
_bluetoothManager.state.listen((state) async {
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: esc_pos_bluetooth
description: The library allows to print receipts using an ESC/POS thermal Bluetooth printer.
version: 0.2.8
version: 0.3.0
homepage: https://github.com/andrey-ushakov/esc_pos_bluetooth

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
rxdart: ^0.23.1
rxdart: ^0.26.0
esc_pos_utils: ^0.3.6
# esc_pos_utils:
# path: ../esc_pos_utils
flutter_bluetooth_basic: ^0.1.5
# path: ../esc_pos_utils
flutter_bluetooth_basic: ^0.1.6

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 75bd25c

Please sign in to comment.