brady_flutter_plugin 2.0.0+1 brady_flutter_plugin: ^2.0.0+1 copied to clipboard
The official Flutter Plugin to integrate the Brady SDK within a Flutter application. The Brady SDK will allow users to discovery, connect, and print to Brady printers.
brady_flutter_plugin #
This is the official Flutter Plugin to integrate the Brady SDK within a Flutter application. The Brady SDK will allow users to communicate with Brady printers. The API will allow the functionality of discovering printers, connecting to printers, retrieving printer details, setting a template or image to print, and printing labels (to name a few).
Getting Started #
- Add the following dependency to your pubspec.yaml: brady_flutter_plugin: ^2.0.0+1
- To demonstrate the basic functionalities of the Brady SDK Flutter Plugin, copy and paste the main.dart under the "example" tab into a fresh Flutter project.
- For additional information about platform specific documentation, refer to https://sdk.bradyid.com
- For the example app to work, you must provide an image or template (.BWT file) to print. Add the following to the pubspec.yaml: under the "flutter" block:
assets:
- assets/
- Now, at the root of your project, create a folder named "assets" and place all images and templates (.BWT files) here.
Android Setup #
- It is recommended to change minSdkVersion in your app/build.gradle to 26.
- Flutter applications will still build if minSdkVersion is lower than 26. However the SDK will not communicate with printers if the mobile device is less than 26 (Android 8).
- When developing a Flutter application for Android, the "buildTypes" block in the "app/build.gradle" must be changed to the following:
buildTypes {
release {
//The following two lines ensure that no third-party library classes get ignored at compile-time.
//This is crucial because the Brady Android SDK depends on these classes to make a successful connection.
shrinkResources false
minifyEnabled false
signingConfig signingConfigs.debug
}
}
iOS Setup #
- It is recommended to use the widely used Flutter Permissions library to handle permissions.
- Add the following to your Flutter app's pubspec.yaml: "permission_handler: ^11.3.1"
- Add the following permissions to your Podfile's post_install:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# You can remove unused permissions here
# for more information:
https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handle
r/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.calendar
'PERMISSION_EVENTS=0',
## dart: PermissionGroup.reminders
'PERMISSION_REMINDERS=0',
## dart: PermissionGroup.contacts
'PERMISSION_CONTACTS=0',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=0',
## dart: PermissionGroup.speech
'PERMISSION_SPEECH_RECOGNIZER=0',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=0',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways,
PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
'PERMISSION_LOCATION_ALWAYS=1',
'PERMISSION_LOCATION_WHENINUSE=1',
‹
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=0',
## dart: PermissionGroup.mediaLibrary
'PERMISSION_MEDIA_LIBRARY=0',
## dart: PermissionGroup.sensors
'PERMISSION_SENSORS=0',
## dart: PermissionGroup.bluetooth
'PERMISSION_BLUETOOTH=1',
## dart: PermissionGroup.appTrackingTransparency
'PERMISSION_APP_TRACKING_TRANSPARENCY=0',
## dart: PermissionGroup.criticalAlerts
'PERMISSION_CRITICAL_ALERTS=0',
]
end
end
end
- Add the following permissions to your info.plist:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSLocalNetworkUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSLocationUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSBonjourServices</key>
<array>
<string>_pdl-datastream._tcp.</string>
</array>
- Show a permissions request to your user with the following code:
Map<Permission, PermissionStatus> statuses = await [
Permission.bluetooth,
Permission.bluetoothConnect,
Permission.bluetoothScan,
Permission.nearbyWifiDevices,
Permission.locationWhenInUse
].request();