본문 바로가기

프로그래밍

(287)
[flutter] 특정 값에 따라 Widget 변경 Widget을 업데이트 할 경우 setState(() {}) 를 사용하면 되는데, setState()는 전체 Widget을 초기화하고, build 메쏘드를 호출해 전체 Widget을 다시 생성하게 된다. 특정 Widget만 초기화 하려면 별도의 publisher와 Widget을 사용해야 한다. ValueNotifier 값의 변화를 퍼블리싱하는 객체 ValueNotifier _isSignIn = ValueNotifier(false); ValueListenableBuilder ValueNotifier 의 값이 변경되면 builder 에 정의한 메쏘드가 호출된다. 위의 bool 값에 따라 버튼을 활성화, 비활성화 하는 경우 아래와 같이 구성된다. @override Widget build(BuildContext..
[flutter] Plugin UIView 사용하기 Context 뷰 인스턴스를 저장하기 위한 저장소 클래스 class Context { var sampleView: SampleView? } FlutterPlatformView UIView를 포함하고 있는 FlutterPlatformView 구성 class SampleView: NSObject, FlutterPlatformView { private let id: Int64 private var uiView: UIView init(frame: CGRect, viewIdentifier viewId: Int64, arguments arg: Any?, binaryMessenger messenger: FlutterBinaryMessenger?) { self.id = viewId self.uiView = UIView..
[flutter] ios plugin 에서 local framework 설정 테스트 환경 cocoapods : 1.12.0 xcode : 14.2 플러그인 ios 네이티브 코드 작성시 로컬 프레임워크인 MyFrameworkA.xcframework 와 MyFrameworkB.xcframework 를 사용하는 경우 아래와 같이 설정한다. /my_plugin/ios/ 폴더에 프레임워크 각 프레임워크 복사 /my_plugin/ios/my_plugin.podspec 수정 podspec dependency 에서 로컬 프레임워크를 지원하지 않으므로, vendored_frameworks 로 관련 프레임워크들을 묶어 주어야 한다. s.source = { :path => '.' } s.source_files = 'Classes/**/*' s.xcconfig = { 'OTHER_LDFLAGS' =>..
[flutter] 플러그인 프로젝트 구현 절차 플러그인 프로젝트 생성 flutter create --org com.example --template=plugin --platforms=android,ios -i swift my_plugin /pubspec.yaml 인터페이스 만들기 /lib 하위에 dart 클래스를 구성 네이티브 인터페이스 네이티브 인터페이스 클래스 native와 연결될 메쏘드들을 정의할 인터페이스 클래스 생성. abstract class MyPluginPlatform extends PlatformInterface { MyPluginPlatform() : super(token: _token); static final Object _token = Object(); static MyPluginPlatform _instance = MyPlu..
[flutter] 플러그인 프로젝트 자동 생성 요소 1. 플러그인 프로젝트 생성 flutter create --org com.example --template=plugin --platforms=android,ios -i swift hello_world /pubspec.yaml flutter: plugin: ios: pluginClass: HelloWorldPlugin 2. API 구현 1) PlatformInterface 플랫폼 api 정의 lib/hello_world_platform_interface.dart 자동생성 코드는 정의부와 구현부를 분리하기 위해 별도 클래스를 생성 기본적인 인스턴스 할당과 구현이 필요한 인터페이스 메쏘드들을 정의 import 'package:plugin_platform_interface/plugin_platform_inter..
[flutter] ios 기본 모듈 구성 방식 Integrate a Flutter module into your iOS project | Flutter Integrate a Flutter module into your iOS project Learn how to integrate a Flutter module into your existing iOS project. docs.flutter.dev 모듈 만들기 cd some/path/ flutter create --template module my_module 기본 구성요소 Runner xcode 프로젝트와 워크스페이스 : ./.ios (숨김폴더) dart 소스 : ./lib 테스트 : ./test flutter 프로젝트 정보 : ./pubspec.yaml ./.ios 폴더의 경우 자동 생성 및 수정이..
[concurrency] Task, TaskGroup, task timeout Task @frozen struct Task where Success: Sendable, Failure: Error init(priority: TaskPriority?, operation: () async -> Success) init(priority: TaskPriority?, operation: () async throws -> Success) TaskGroup @frozen struct TaskGroup where ChildTaskResult: Sendable TaskGroup은 별도의 메서드를 사용해 생성해야 하며, 생성된 task 내에서만 사용해야 함. 주요함수 func addTask(priority: TaskPriority?, operation: () async -> ChildTaskResul..
github ssh 설정 ssh 키 생성 ssh-keygen -t rsa -C "email" 공개키 등록 공개키(pub) 파일내용을 github > Settings > SSH and GPG Keys 에서 ssh 키 등록 config 생성 host는 실제가 아닌 구분을 위한 이름으로 remote 등록시에 사용된다. Host id1.github.com HostName github.com IdentityFile ~/.ssh/개인키1_파일명 User git Host id2.github.com HostName github.com IdentityFile ~/.ssh/개인키2_파일명 User git Port 22 git remote 등록 SSH를 사용하는 경우 http와는 다른 url 형식 사용 git@host 중 host는 실제 도메인이 ..