Flutter lightweight ToolTip control

Tip light effect in the application is indispensable, in fact Flutter ready light prompt controls, this is toolTip.

Lightweight operating tips

In fact, there are many tips Flutter controls, for example Dialog, Snackbarand BottomSheetthese operations are relatively heavyweight, long time or they will interrupt the user on the screen of the operation exists.

Of course not to say that these controls are not good, according to different needs, have a variety of options, so will everyone to talk about lightweight operating tipsTooltip。

TooltipInherited from StatefulWidgeta Widget, it does not need to call up the method, when the user presses the Tooltipparcel of Widget, the corresponding operation will automatically pop up prompt.

Child: Tooltip ( // Lightweight prompt 
        the Message: " the Do not Touch " , 
        Child: Image.asset ( ' ImagesRF Royalty Free / lake.jpg ' ), 
),

The complete code is as follows:

import 'package:flutter/material.dart';

void main()=> runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title:'Flutter Demo',
      theme:ThemeData.light(),
      home: ToolTipDemo(),
    );
  }
}

class ToolTipDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title:Text('tool tips demo')),
      body:Center(
        child: Tooltip(
          message: "Don't touch 不要碰 ",
          child: Image.asset('images/lake.jpg'),
        ),
      )
    );
  }
}

 

Guess you like

Origin www.cnblogs.com/joe235/p/11236861.html