$ flutter create appname
$ flutter devices -v
$ flutter emulators
Pixel_XL_API_28 • Pixel XL API 28 • Google • android
apple_ios_simulator • iOS Simulator • Apple • ios
$ flutter emulators --launch apple_ios_simulator
$ flutter run
localhost をスマホ実機で確認する方法 iPhone から localhost で起動しているアプリにアクセス
assets/json/deep_anime_api.json
のAPI_URIを以下のように書き換え
saneatsuの部分は自身のMacPC名にすること
MacのPCの名前はシステム設定の共有から確認
{
...
"API_URI": "http://saneatsu.local:3000"
}
android端末からPCのローカルサーバにアクセスする方法
Androidアプリ開発中にAndroid実機を認識しなくなった時の対処方法
assets/json/deep_anime_api.json
のAPI_URIを以下のように書き換え
{
...
"API_URI": "http://10.0.2.2:3000" // エミュレーターの場合
}
"http://localhost:3000"
だと以下のエラーが発生する
"http://192.168.179.5:3000"
実機の場合はMacのIPアドレスにする
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 35779 #16
$ flutter devices
1 connected device:
WAS LX2J • P3PDU18316006143 • android-arm64 • Android 7.0 (API 24)
$ flutter run -d P3PDU18316006143
VSCodeを使っている場合は「Fn + F5」
https://qiita.com/ishihamat/items/a897754eed6b5c1ec6ed
or
https://github.com/flutter/flutter/issues/13065#issuecomment-441802877
cd ios
xcodebuild -workspace Runner.xcworkspace -scheme Runner -sdk iphoneos -configuration Release archive -archivePath $PWD/build/Runner.xcarchive
xcodebuild -allowProvisioningUpdates -exportArchive -archivePath $PWD/build/Runner.xcarchive -exportOptionsPlist exportOptions.plist -exportPath $PWD/build/Runner.ipa
$ open ~/Library/MobileDevice/Provisioning\ Profiles/
Finderで開いてスペースで開いてどのファイルか確認
$ curl -O https://raw.githubusercontent.com/InderKumarRathore/ListProvisioningProfileName/master/list-provisioning-profile-name.sh
$ chmod +x list-provisioning-profile-name.sh
$ bash list-provisioning-profile-name.sh
saneatsuwakana at saneatsu in ~
$ bash list-provisioning-profile-name.sh
Provisioning Profile Folder: cd ~/Library/MobileDevice/Provisioning\ Profiles/
020be5e2-7782-4797-832a-74664f422d79.mobileprovision chatbot_mobile
256ab240-7594-47ce-a5bd-7a567603e6f1.mobileprovision poseandclassification
58d6d6ae-5b9f-4eb0-8802-9bbf592569e1.mobileprovision ios team provisioning profile: com.algoage.deepanime
711389b8-8995-425f-8d33-f81170a77127.mobileprovision ios team provisioning profile: *
75497611-94ba-4871-8546-1c599b960b78.mobileprovision deepanime ← これ!
782a89d3-c369-470f-b68c-6a2730ae05b7.mobileprovision ios team provisioning profile: net.algoage.chatbotmobile
78702b93-d067-4d98-9673-61a0b540a60b.mobileprovision poseandclassificationdemotest
a3b4cfb1-5288-46a6-b0e8-f2a25d19b750.mobileprovision ios team store provisioning profile: com.algoage.deepanime
b03736ff-29c4-4a6c-bf49-f6a1a1255bea.mobileprovision animeafreco
dcfb0473-e7e1-4f1d-b453-af1350a1998f.mobileprovision ios team store provisioning profile: net.algoage.chatbotmobile
https://developer.apple.com/account/#/overview/QL469279ML このページから契約内容に同意する。
参考
https://www.codevscolor.com/dart-iterate-map/
この方法はワンライナーでなくちゃいけないので注意。 Text以外にも入れ子のWidgetを使いたい場合は別に関数としてWidgetを定義すること
final int timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).round();
Top 10 Array utility methods you should know (Dart) 🎯
How do I disable a Button in Flutter?
List _sample = ['a','b','c'];
_sample.asMap().forEach((index, value) => f);
Enumerate or map through a list with index and value in Dart
How to get value of some field in firebase firestore android?
// full screen width and height
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
// height without SafeArea
var padding = MediaQuery.of(context).padding;
double height1 = height - padding.top - padding.bottom;
// height without status bar
double height2 = height - padding.top;
// height without status and toolbar
double height3 = height - padding.top - kToolbarHeight;
下の方法もあるが、deep_anime_mobileではMultiImagePickerを利用してbyteDataをとってきてそれを変換した。
https://github.com/flutter/flutter/issues/20522#issuecomment-520175936
try {
selectedImages = await MultiImagePicker.pickImages(
maxImages: 3,
enableCamera: true,
);
for (var image in selectedImages) {
ByteData byteData = await image.getByteData();
imageFiles.add(
byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes)
);
}
List images = [];
for (int i=0; i<selectedImages.length; i++) {
images.add(
UploadFileInfo.fromBytes(
selectedImages[i],
'image_$i.png',
contentType: ContentType('image', 'png')
)
);
}
} catch (e) {
print(e.message);
}
pathというデフォルトで用意されているライブラリを使う。 拡張子だけ撮ってくるときにも使える便利。
import 'package:path/path.dart' as p;
String extension = p.extension(image.name);
https://stackoverflow.com/questions/50439949/flutter-get-the-filename-of-a-file
enum Fruit { apple, banana }
// Convert to string
String str = Fruit.banana.toString();
// Convert to enum
// Fruit f = Fruit.values.firstWhere((e) => e.toString() == str);
Fruit f = Fruit.values.firstWhere((e) => e.toString() == 'Fruit.' + str);
assert(f == Fruit.banana); // it worked
https://stackoverflow.com/questions/27673781/enum-from-string
https://makicamel.hatenablog.com/entry/2019/03/14/213933