flutter で、os 毎に処理を分岐するには?

import 'dart:io';

// ...

if (Platform.isAndroid) {
  // Android用の処理
} else if (Platform.isIOS) {
  // iOS用の処理
} else {
  // その他のプラットフォーム用の処理
}

wakelock ライブリをつかったらiOS だとエラーが発生して動作しなかった。

とりあえず必須でないので外す

2023-06-24 18:51:29.561174+0900 Runner[486:41614] Metal API Validation Enabled
2023-06-24 18:51:29.703009+0900 Runner[486:41614] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(35)] Using the Impeller rendering backend.
2023-06-24 18:51:30.255519+0900 Runner[486:41912] flutter: The Dart VM service is listening on http://127.0.0.1:58922/2zlyqqf60mY=/
2023-06-24 18:51:30.882812+0900 Runner[486:41614] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSConcreteData getBytes:range:]: range {14, 1} exceeds data length 14'
*** First throw call stack:
(0x1922a725c 0x1a603c480 0x1934e2e70 0x100c76d84 0x100c75744 0x100c76cc0 0x100c75744 0x100c76564 0x100c728d0 0x1006ccb80 0x102dc7ae8 0x102dc932c 0x102dd776c 0x192226298 0x1922206f8 0x19221f7d0 0x1a8961570 0x194b4c2d0 0x194b5184c 0x100209a80 0x191efe140)
libc++abi: terminating with uncaught exception of type NSException
(lldb)

 

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

© 2024 Falco Tech Blog Suffusion theme by Sayontan Sinha