Skip to content

Commit 2249102

Browse files
feat: added appbar title and center title field
1 parent 4abc91e commit 2249102

File tree

8 files changed

+50
-13
lines changed

8 files changed

+50
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@
2828

2929
## 0.0.6
3030
* Document update
31-
* warning update
31+
* warning update
32+
33+
34+
## 0.0.7
35+
* Fixed performance issue with window [5](https://github.com/CodingWithTashi/simple_barcode_scanner/issues/5)
36+
* Added appBar title and centerTitle param [11](https://github.com/CodingWithTashi/simple_barcode_scanner/issues/11)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Window | Web
2727
## Getting started
2828

2929
```dart
30-
simple_barcode_scanner: ^0.0.6
30+
simple_barcode_scanner: ^0.0.7
3131
3232
```
3333
Import the library:

lib/screens/io_device.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:io';
2+
23
import 'package:flutter/material.dart';
34
import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
45
import 'package:simple_barcode_scanner/enum.dart';
@@ -11,14 +12,17 @@ class BarcodeScanner extends StatelessWidget {
1112
final bool isShowFlashIcon;
1213
final ScanType scanType;
1314
final Function(String) onScanned;
14-
15+
final String? appBarTitle;
16+
final bool? centerTitle;
1517
const BarcodeScanner({
1618
Key? key,
1719
required this.lineColor,
1820
required this.cancelButtonText,
1921
required this.isShowFlashIcon,
2022
required this.scanType,
2123
required this.onScanned,
24+
this.appBarTitle,
25+
this.centerTitle,
2226
}) : super(key: key);
2327

2428
@override
@@ -31,6 +35,8 @@ class BarcodeScanner extends StatelessWidget {
3135
isShowFlashIcon: isShowFlashIcon,
3236
scanType: scanType,
3337
onScanned: onScanned,
38+
appBarTitle: appBarTitle,
39+
centerTitle: centerTitle,
3440
);
3541
} else {
3642
/// Scan Android and ios barcode scanner with flutter_barcode_scanner

lib/screens/unsupported.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ class BarcodeScanner extends StatelessWidget {
77
final bool isShowFlashIcon;
88
final ScanType scanType;
99
final Function(String) onScanned;
10+
final String? appBarTitle;
11+
final bool? centerTitle;
1012
const BarcodeScanner(
1113
{Key? key,
1214
this.lineColor = "#ff6666",
1315
this.cancelButtonText = "Cancel",
1416
this.isShowFlashIcon = false,
1517
this.scanType = ScanType.barcode,
16-
required this.onScanned})
18+
required this.onScanned,
19+
this.appBarTitle,
20+
this.centerTitle})
1721
: super(key: key);
1822

1923
@override

lib/screens/web.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import 'package:flutter/material.dart';
2-
import 'package:simple_barcode_scanner/constant.dart';
3-
import 'package:simple_barcode_scanner/enum.dart';
41
// ignore: avoid_web_libraries_in_flutter
52
import 'dart:html' as html;
63
import 'dart:ui' as ui;
74

5+
import 'package:flutter/material.dart';
6+
import 'package:simple_barcode_scanner/constant.dart';
7+
import 'package:simple_barcode_scanner/enum.dart';
8+
89
/// Barcode scanner for web using iframe
910
class BarcodeScanner extends StatelessWidget {
1011
final String lineColor;
1112
final String cancelButtonText;
1213
final bool isShowFlashIcon;
1314
final ScanType scanType;
1415
final Function(String) onScanned;
16+
final String? appBarTitle;
17+
final bool? centerTitle;
1518

1619
const BarcodeScanner({
1720
Key? key,
@@ -20,6 +23,8 @@ class BarcodeScanner extends StatelessWidget {
2023
required this.isShowFlashIcon,
2124
required this.scanType,
2225
required this.onScanned,
26+
this.appBarTitle,
27+
this.centerTitle,
2328
}) : super(key: key);
2429

2530
@override
@@ -47,7 +52,8 @@ class BarcodeScanner extends StatelessWidget {
4752

4853
return Scaffold(
4954
appBar: AppBar(
50-
title: Text(kScanPageTitle),
55+
title: Text(appBarTitle ?? kScanPageTitle),
56+
centerTitle: centerTitle,
5157
),
5258
body: HtmlElementView(
5359
viewType: createdViewId,

lib/screens/window.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class WindowBarcodeScanner extends StatelessWidget {
1313
final bool isShowFlashIcon;
1414
final ScanType scanType;
1515
final Function(String) onScanned;
16+
final String? appBarTitle;
17+
final bool? centerTitle;
1618

1719
const WindowBarcodeScanner({
1820
Key? key,
@@ -21,6 +23,8 @@ class WindowBarcodeScanner extends StatelessWidget {
2123
required this.isShowFlashIcon,
2224
required this.scanType,
2325
required this.onScanned,
26+
this.appBarTitle,
27+
this.centerTitle,
2428
}) : super(key: key);
2529

2630
@override
@@ -29,7 +33,8 @@ class WindowBarcodeScanner extends StatelessWidget {
2933
bool isPermissionGranted = false;
3034
return Scaffold(
3135
appBar: AppBar(
32-
title: Text(kScanPageTitle),
36+
title: Text(appBarTitle ?? kScanPageTitle),
37+
centerTitle: centerTitle,
3338
leading: IconButton(
3439
onPressed: () {
3540
/// send close event to web-view

lib/simple_barcode_scanner.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
library simple_barcode_scanner;
22

3-
export 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
43
import 'package:flutter/material.dart';
54
import 'package:simple_barcode_scanner/enum.dart';
65
import 'package:simple_barcode_scanner/screens/shared.dart';
76

7+
export 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
8+
89
class SimpleBarcodeScannerPage extends StatelessWidget {
910
///Barcode line color default set to #ff6666
1011
final String lineColor;
@@ -18,14 +19,22 @@ class SimpleBarcodeScannerPage extends StatelessWidget {
1819
///Enter enum scanType, It can be BARCODE, QR, DEFAULT
1920
final ScanType scanType;
2021

21-
///All param only support for mobile and tab,
22-
///desktop and web is not yet support
22+
///AppBar Title
23+
final String? appBarTitle;
24+
25+
///center Title
26+
final bool? centerTitle;
27+
28+
/// appBatTitle and centerTitle support in web and window only
29+
/// Remaining field support in only mobile devices
2330
const SimpleBarcodeScannerPage({
2431
Key? key,
2532
this.lineColor = "#ff6666",
2633
this.cancelButtonText = "Cancel",
2734
this.isShowFlashIcon = false,
2835
this.scanType = ScanType.barcode,
36+
this.appBarTitle,
37+
this.centerTitle,
2938
}) : super(key: key);
3039

3140
@override
@@ -35,6 +44,8 @@ class SimpleBarcodeScannerPage extends StatelessWidget {
3544
cancelButtonText: cancelButtonText,
3645
isShowFlashIcon: isShowFlashIcon,
3746
scanType: scanType,
47+
appBarTitle: appBarTitle,
48+
centerTitle: centerTitle,
3849
onScanned: (res) {
3950
Navigator.pop(context, res);
4051
},

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: simple_barcode_scanner
22
description: Scanner plugin for Barcode/QR code. Scan using flutter_barcode_scanner for mobile device and html5-qrcode for web and windows
3-
version: 0.0.6
3+
version: 0.0.7
44
homepage: https://github.com/CodingWithTashi/simple_barcode_scanner
55
issue_tracker: https://github.com/CodingWithTashi/simple_barcode_scanner/issues
66

0 commit comments

Comments
 (0)