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

Adding null safety support #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions qrcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ To use on iOS, you must add the following to your Info.plist
<key>io.flutter.embedded_views_preview</key>
<true/>
```

### Android
To use on Android, increase the project's minSdk version to at least 24
6 changes: 3 additions & 3 deletions qrcode/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 30

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -39,8 +39,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.qrcode_example"
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 24
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
30 changes: 17 additions & 13 deletions qrcode/lib/qrcode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ typedef CaptureCallback(String data);
enum CaptureTorchMode { on, off }

class QRCaptureController {
MethodChannel _methodChannel;
CaptureCallback _capture;
MethodChannel? _methodChannel;
CaptureCallback? _capture;

QRCaptureController();

void _onPlatformViewCreated(int id) {
_methodChannel = MethodChannel('plugins/qr_capture/method_$id');
_methodChannel.setMethodCallHandler((MethodCall call) async {
if (call.method == 'onCaptured') {
_methodChannel!.setMethodCallHandler((MethodCall call) async {
if (call.method == 'onCaptured') {
if (_capture != null && call.arguments != null) {
_capture(call.arguments.toString());
_capture!(call.arguments.toString());
}
}
});
Expand All @@ -44,7 +44,11 @@ class QRCaptureController {

class QRCaptureView extends StatefulWidget {
final QRCaptureController controller;
QRCaptureView({Key key, this.controller}) : super(key: key);

QRCaptureView({
Key? key,
required this.controller,
}) : super(key: key);

@override
State<StatefulWidget> createState() {
Expand All @@ -53,24 +57,24 @@ class QRCaptureView extends StatefulWidget {
}

class QRCaptureViewState extends State<QRCaptureView> {

@override
Widget build(BuildContext context) {
if (Platform.isIOS) {
return UiKitView(
viewType: 'plugins/qr_capture_view',
creationParamsCodec: StandardMessageCodec(),
onPlatformViewCreated: (id) {
viewType: 'plugins/qr_capture_view',
creationParamsCodec: StandardMessageCodec(),
onPlatformViewCreated: (id) {
widget.controller._onPlatformViewCreated(id);
},
);
} else {
return AndroidView(viewType: 'plugins/qr_capture_view',
return AndroidView(
viewType: 'plugins/qr_capture_view',
creationParamsCodec: StandardMessageCodec(),
onPlatformViewCreated: (id) {
widget.controller._onPlatformViewCreated(id);
},
);
}
}
}
}
43 changes: 2 additions & 41 deletions qrcode/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: chendaxin <[email protected]>
homepage: https://github.com/SiriDx/qrcode

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

dependencies:
flutter:
Expand All @@ -15,46 +15,7 @@ dev_dependencies:
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
# This section identifies this Flutter project as a plugin project.
# The androidPackage and pluginClass identifiers should not ordinarily
# be modified. They are used by the tooling to maintain consistency when
# adding or updating assets for this project.
plugin:
androidPackage: com.example.qrcode
pluginClass: QrcodePlugin

# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.dev/custom-fonts/#from-packages
pluginClass: QrcodePlugin