【问题标题】:Hello, how i can create a curved shape app bar in flutter as per image?您好,我如何根据图像在颤动中创建弯曲形状的应用栏?
【发布时间】:2021-12-29 01:11:56
【问题描述】:

返回强文本脚手架(

应用栏:应用栏( 领导:墨水井( 孩子:SvgPicture.asset( '资产/arrow.svg', ), 点按:(){ Navigator.pop(上下文); }, ));

【问题讨论】:

标签: flutter


【解决方案1】:
class MyHomePage extends StatelessWidget {

  final double topWidgetHeight = 200.0;
  final double avatarRadius = 50.0;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Stack(
        children: <Widget>[
          new Column(
            children: <Widget>[
              new Container(
                height: topWidgetHeight,
                color: Colors.yellow,
              ),
              new Container(
                color: Colors.red,
              )
            ],
          ),
          new Positioned(
            child: new CircleAvatar(
              radius: avatarRadius,
              backgroundColor: Colors.green,
            ),
            left: (MediaQuery.of(context).size.width/2) - avatarRadius,
            top: topWidgetHeight - avatarRadius,
          )
        ],
      ),
    );
  }
}

【讨论】:

    【解决方案2】:

    试试下面的代码。

     import 'package:flutter/material.dart';
    
    class AppBarOnly extends StatelessWidget {
      const AppBarOnly({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.blue[800],
            title: Padding(
              padding: EdgeInsets.only(top: 80.0),
              child: CircleAvatar(
                backgroundColor: Colors.white,
                // backgroundImage: AssetImage(''),
                radius: 60,
                child: Padding(
                  padding: EdgeInsets.only(bottom: 50.0),
                  child: Text(
                    'Logo Here',
                    style: TextStyle(
                        color: Colors.black,
                        fontWeight: FontWeight.bold,
                        fontSize: 18.0),
                  ),
                ),
              ),
            ),
          ),
        );
      }
    }
    

    注意:更改应用栏的背景颜色以满足您的需要

    【讨论】:

    • 你已经完成了 90% 的工作,但我原来的 appbar 是这个
    • 那你做到了吗?
    • 您的代码工作正常,但是当我放置图像时,图像被剪切了 50%。
    猜你喜欢
    • 2021-11-29
    • 2020-11-23
    • 1970-01-01
    • 2020-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    相关资源
    最近更新 更多