Flutter CupertinoPopupSurface


简介

像iOS弹出式表面

  • 快速实现一个圆角弹框,类似 alert dialog 和 sheet;

实例演示

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/*
* CupertinoPopupSurface 默认的实例
* */
class CupertinoPopupSurfaceFullDefault extends StatefulWidget {
  const CupertinoPopupSurfaceFullDefault() : super();

  @override
  State<StatefulWidget> createState() => _CupertinoPopupSurfaceFullDefault();
}

/*
* CupertinoPopupSurface 默认的实例,有状态
* */
class _CupertinoPopupSurfaceFullDefault extends State {
  @override
  Widget build(BuildContext context) {
    return SizedBox(
        height: MediaQuery.of(context).size.height/5,
        child: cupertinoPopupSurfaceBar(context)
    );
  }

  Widget cupertinoPopupSurfaceBar(BuildContext context) {
    return CupertinoPopupSurface(
      isSurfacePainted:false,
      child: Container(
          color: CupertinoColors.inactiveGray,
          alignment: Alignment.center,
          child: Text('这里是内容', style: TextStyle(color: Colors.white))
      ), // 应用程序默认路由,(Navigator.defaultRouteName,即/)
    );
  }
}