Skip to content

Commit

Permalink
format code ready upload to pub.dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyme committed Feb 27, 2020
1 parent 7118765 commit 7ef9435
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
31 changes: 16 additions & 15 deletions example/lib/scan_camera_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class _RScanCameraDialogState extends State<RScanCameraDialog> {
),
);
}

Future<bool> getFlashMode() async {
bool isOpen = false;
try {
Expand All @@ -87,21 +88,21 @@ class _RScanCameraDialogState extends State<RScanCameraDialog> {
Widget _buildFlashBtn(BuildContext context, AsyncSnapshot<bool> snapshot) {
return snapshot.hasData
? Padding(
padding: EdgeInsets.only(bottom:24+MediaQuery.of(context).padding.bottom),
child: IconButton(
icon: Icon(snapshot.data ? Icons.flash_on : Icons.flash_off),
color: Colors.white,
iconSize: 46,
onPressed: () {
if (snapshot.data) {
_controller.setFlashMode(false);
} else {
_controller.setFlashMode(true);
}
setState(() {});
}),
)
padding: EdgeInsets.only(
bottom: 24 + MediaQuery.of(context).padding.bottom),
child: IconButton(
icon: Icon(snapshot.data ? Icons.flash_on : Icons.flash_off),
color: Colors.white,
iconSize: 46,
onPressed: () {
if (snapshot.data) {
_controller.setFlashMode(false);
} else {
_controller.setFlashMode(true);
}
setState(() {});
}),
)
: Container();
}

}
29 changes: 15 additions & 14 deletions example/lib/scan_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,21 @@ class _RScanDialogState extends State<RScanDialog> {
Widget _buildFlashBtn(BuildContext context, AsyncSnapshot<bool> snapshot) {
return snapshot.hasData
? Padding(
padding: EdgeInsets.only(bottom:24+MediaQuery.of(context).padding.bottom),
child: IconButton(
icon: Icon(snapshot.data ? Icons.flash_on : Icons.flash_off),
color: Colors.white,
iconSize: 46,
onPressed: () {
if (snapshot.data) {
_controller.setFlashMode(false);
} else {
_controller.setFlashMode(true);
}
setState(() {});
}),
)
padding: EdgeInsets.only(
bottom: 24 + MediaQuery.of(context).padding.bottom),
child: IconButton(
icon: Icon(snapshot.data ? Icons.flash_on : Icons.flash_off),
color: Colors.white,
iconSize: 46,
onPressed: () {
if (snapshot.data) {
_controller.setFlashMode(false);
} else {
_controller.setFlashMode(true);
}
setState(() {});
}),
)
: Container();
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main() {
// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) => widget is Text &&
widget.data.startsWith('Running on:'),
(Widget widget) =>
widget is Text && widget.data.startsWith('Running on:'),
),
findsOneWidget,
);
Expand Down
9 changes: 3 additions & 6 deletions lib/r_scan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export 'package:r_scan/src/r_scan_camera.dart';

/// qr scan
class RScan {
static const MethodChannel _channel = const MethodChannel('com.rhyme_lph/r_scan');
static const MethodChannel _channel =
const MethodChannel('com.rhyme_lph/r_scan');

/// scan qr image in path
///
Expand Down Expand Up @@ -43,8 +44,6 @@ class RScan {
}));
}



/// barcode type
enum RScanBarType {
azetc,
Expand Down Expand Up @@ -104,7 +103,6 @@ class RScanResult {
///barcode points
final List<RScanPoint> points;


const RScanResult({this.type, this.message, this.points});

factory RScanResult.formMap(Map map) {
Expand Down Expand Up @@ -143,6 +141,5 @@ class RScanResult {
points == other.points;

@override
int get hashCode =>
type.hashCode ^ message.hashCode ^ points.hashCode;
int get hashCode => type.hashCode ^ message.hashCode ^ points.hashCode;
}
4 changes: 3 additions & 1 deletion lib/src/r_scan_camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ class RScanCameraController extends ValueNotifier<RScanCameraValue> {

//处理返回值
void _handleResult(event) {
if(_isDisposed) return;
if (_isDisposed) return;
this.result = RScanResult.formMap(event);
notifyListeners();
}

//开始扫描
Future<void> startScan() async {
await _channel.invokeMethod('startScan');
Expand All @@ -76,6 +77,7 @@ class RScanCameraController extends ValueNotifier<RScanCameraValue> {
Future<void> stopScan() async {
await _channel.invokeMethod('stopScan');
}

/// flash mode open or close.
///
/// [isOpen] if false will close flash mode.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/r_scan_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ class _RScanViewState extends State<RScanView> {
};
Widget child;
if (Platform.isAndroid) {
child= AndroidView(
child = AndroidView(
viewType: _scanType,
onPlatformViewCreated: onPlatformViewCreated,
creationParams: params,
creationParamsCodec: StandardMessageCodec(),
);
} else if (Platform.isIOS) {
child= UiKitView(
child = UiKitView(
viewType: _scanType,
onPlatformViewCreated: onPlatformViewCreated,
creationParams: params,
Expand Down Expand Up @@ -132,4 +132,4 @@ class RScanController extends ChangeNotifier {
_subscription?.cancel();
notifyListeners();
}
}
}
3 changes: 1 addition & 2 deletions test/r_scan_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ void main() {
channel.setMockMethodCallHandler(null);
});

test('getPlatformVersion', () async {
});
test('getPlatformVersion', () async {});
}

0 comments on commit 7ef9435

Please sign in to comment.