当某个组件外边封装有Tooltip时,点击这个组件或鼠标放上后,会有提示信息。
有的组件本身带有tooltip属性。
/// Flutter code sample for Tooltip
// This example show a basic [Tooltip] which has a [Text] as child.
// [message] contains your label to be shown by the tooltip when
// the child that Tooltip wraps is hovered over on web or desktop. On mobile,
// the tooltip is shown when the widget is long pressed.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
/// This is the main application widget.
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const Center(
child: MyStatelessWidget(),
),
),
);
}
}
/// This is the stateless widget that the main applica

本文介绍如何在Flutter中利用Tooltip为组件提供提示,包括基础Tooltip的创建和在带有Tooltip的Text组件上的应用。通过示例代码演示了如何在Web和移动端实现不同的交互效果。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



