dart - flutter 圈设计

我想用这些白色圆圈作为凸起的按钮进行这种设计。

最佳答案

试试这个!

我添加了 5 个圈子,您可以添加更多。而不是 RaisedButton 使用 InkResponse

import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(home: new ExampleWidget()));
}

class ExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Widget bigCircle = new Container(
      width: 300.0,
      height: 300.0,
      decoration: new BoxDecoration(
        color: Colors.orange,
        shape: BoxShape.circle,
      ),
    );

    return new Material(
      color: Colors.black,
      child: new Center(
        child: new Stack(
          children: <Widget>[
            bigCircle,
            new Positioned(
              child: new CircleButton(onTap: () => print("Cool"), iconData: Icons.favorite_border),
              top: 10.0,
              left: 130.0,
            ),
            new Positioned(
              child: new CircleButton(onTap: () => print("Cool"), iconData: Icons.timer),
              top: 120.0,
              left: 10.0,
            ),
            new Positioned(
              child: new CircleButton(onTap: () => print("Cool"), iconData: Icons.place),
              top: 120.0,
              right: 10.0,
            ),
            new Positioned(
              child: new CircleButton(onTap: () => print("Cool"), iconData: Icons.local_pizza),
              top: 240.0,
              left: 130.0,
            ),
            new Positioned(
              child: new CircleButton(onTap: () => print("Cool"), iconData: Icons.satellite),
              top: 120.0,
              left: 130.0,
            ),
          ],
        ),
      ),
    );
  }
}

class CircleButton extends StatelessWidget {
  final GestureTapCallback onTap;
  final IconData iconData;

  const CircleButton({Key key, this.onTap, this.iconData}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double size = 50.0;

    return new InkResponse(
      onTap: onTap,
      child: new Container(
        width: size,
        height: size,
        decoration: new BoxDecoration(
          color: Colors.white,
          shape: BoxShape.circle,
        ),
        child: new Icon(
          iconData,
          color: Colors.black,
        ),
      ),
    );
  }
}

关于dart - flutter 圈设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50522237/

相关文章:

dart - 如何在 Flutter 中通过 Navigator 测试导航

dart - 如何在 Flutter 中使一些文本可点击(响应点击)?

dart - 如何使用 flutter 编写按下双后退按钮以退出应用程序

android - 防止对话框在 Flutter 中关闭外部触摸

dart - Flutter 在 `flutter` 命令上失败

android-studio - Flutter Android Studio 构建失败

dart - 触发从小部件到状态对象的函数

dictionary - flutter/Dart : How to access a single

flutter - 如何将焦点转移到 Flutter 中的下一个 TextField?

dart - 如何在 Flutter 中移除 AppBar 前导图标周围的额外填充