全屏浏览
缩小浏览
回到页首

flutter util---->常用的一些工具方法

copy text to clipboard

Clipboard.setData(ClipboardData(text: string));

since Flutter1.9, you can use SelectableText, it enable the copy feature.

get text from clipboard

final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
String content = clipboardData.text;

close the keyboard

// Flutter v1.7.8+hotfix.2
FocusScope.of(context).unfocus();

// Before
FocusScope.of(context).requestFocus(FocusNode());

fix issue ListView inside ListView

add code as follow in the nested ListView

shrinkWrap: true,
physics: ClampingScrollPhysics(),

transparent appbar

Scaffold(
  extendBodyBehindAppBar: true,
  appBar: AppBar(
    backgroundColor: Colors.transparent,
    elevation: 0,
    ....
  )
)

hide the back button in the appbar

AppBar(
  automaticallyImplyLeading: false,
)

To be continue

Everything will be alright because of you.

posted @ 2020-07-03 09:46  huhx  阅读(623)  评论(0编辑  收藏  举报