FRAMEWORK/FLUTTER

Flutter clipboard에 복사하기

나나나나나나나ㅏ나난ㄴ나ㅏ나나 2022. 3. 3. 10:47
728x90

https://api.flutter.dev/flutter/services/Clipboard-class.html

 

Clipboard class - services library - Dart API

Utility methods for interacting with the system's clipboard. Properties hashCode → int The hash code for this object. [...] read-only, inherited runtimeType → Type A representation of the runtime type of the object. read-only, inherited Methods noSuchM

api.flutter.dev

 

플루터에서 지원하는 기본적인 clipboard를 이용하면 간단하게 복사할수있다!

 

여기서 우리는 get Data를 사용할건데 

button을 만들어서 onTap function안에 넣어주면 된다!

Clipboard.setData(ClipboardData(text: "복사하고싶은 데이터 추가"));

 

 

GestureDetector(
  onTap: (){
    Clipboard.setData(ClipboardData(text: "복사하고싶은거 넣기"));

  },
  child: Container(
    margin: EdgeInsets.only(left: 3),
    width: 33,
    height: 19,
    decoration: BoxDecoration(
      border: Border.all(
        width: 1.3,
        color: Color(0xffeaeaea)
      ),
      borderRadius: BorderRadius.all(Radius.circular(2))
    ),
    child: Center(
      child: SpoqaNormalText(
        title: "복사",
        color: Color(0xff868686),
        fontSize: 11,
      ),
    )
  ),
)

 

끝!

728x90