fluttertoast第三方提示
小于 1 分钟
fluttertoast第三方提示
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class Home extends StatefulWidget {
Home({Key key}) : super(key: key);
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
// 封装弹出提示框方法
_toast(){
Fluttertoast.showToast(
msg:"弹出的提示消息内容",//提示信息
toastLength: Toast.LENGTH_SHORT,//长度
gravity: ToastGravity.CENTER,//提示框位置,,现在是居中
timeInSecForIos: 1,//显示时间
backgroundColor: Colors.red,//背景颜色
textColor: Colors.white,//文本颜色
fontSize: 16.0//字体大小
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('轮播组件演示'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
RaisedButton(
child:Text('toast-fluttertoast第三方库'),
onPressed: _toast//没加括号是调用方法,加括号是获取值
)
],
),
)
);
}
}

