如何在Flutter中使两个相接的圆适配所有类型的选项卡和屏幕?

huangapple go评论67阅读模式
英文:

Two circles touching with lines. How to fit this UI for all type of tabs and screens in flutter?

问题

我需要在Flutter中以编程方式实现这一点,适用于所有选项卡和移动屏幕。

英文:

enter image description here

I need to achieve this programmatically in flutter for all tabs and mobile screens.

答案1

得分: 0

尝试这个。

```dart
 Transform.scale(
            scale: .5,
            child: const SizedBox(
              width: 100,
              height: 100,
              child: FlutterLogo(),
            ),
  ),
英文:
  • try this.

 Transform.scale(
            scale: .5,
            child: const SizedBox(
              width: 100,
              height: 100,
              child: FlutterLogo(),
            ),
  ),

答案2

得分: 0

尝试以下基本代码,您可以根据您的需求进行自定义:

Stack(
  children: [
    Container(
      height: 32,
      decoration: BoxDecoration(
        color: Colors.white, borderRadius: BorderRadius.circular(16),
        border: Border.all(color: Colors.tealAccent, width: 2),
      ),
      
    ),Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Container(
          height: 32,
          width: 32,
        margin: const EdgeInsets.all(0),
          decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(16),
            border: Border.all(color: Colors.tealAccent, width: 2),
          ),
          alignment: Alignment.center,
          child: const Icon(Icons.arrow_back_ios, size: 24, color: Colors.tealAccent,)),
      Text('Your Text Here'),
      Container(
          height: 32,
          width: 32,
        margin: const EdgeInsets.all(0),
          decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(16),
            border: Border.all(color: Colors.tealAccent, width: 2),
          ),
          alignment: Alignment.center,
          child: const Icon(Icons.arrow_forward_ios, size: 24, color: Colors.tealAccent,))
    ],
  )
  ],
)
英文:

Try with following basic code, you can customise as your requirement

Stack(
  children: [
    Container(
      height: 32,
      decoration: BoxDecoration(
        color: Colors.white, borderRadius: BorderRadius.circular(16),
        border: Border.all(color: Colors.tealAccent, width: 2),
      ),
      
    ),Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Container(
          height: 32,
          width: 32,
        margin: const EdgeInsets.all(0),
          decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(16),
            border: Border.all(color: Colors.tealAccent, width: 2),
          ),
          alignment: Alignment.center,
          child: const Icon(Icons.arrow_back_ios, size: 24, color: Colors.tealAccent,)),
      Text('Your Text Here'),
      Container(
          height: 32,
          width: 32,
        margin: const EdgeInsets.all(0),
          decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(16),
            border: Border.all(color: Colors.tealAccent, width: 2),
          ),
          alignment: Alignment.center,
          child: const Icon(Icons.arrow_forward_ios, size: 24, color: Colors.tealAccent,))
    ],
  )
  ],
)

答案3

得分: 0

你需要手动调整高度。我已经为你做了一个示例。

class FirstScreen extends StatelessWidget {
  const FirstScreen({Key? key}) : super(key: key);
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SizedBox(
          height: 60,
          width: double.infinity,
          child: Stack(
            children: [
              Positioned(
                top: 0,
                bottom: 0,
                left: 40,
                right: 40,
                child: Container(
                  constraints: const BoxConstraints.expand(),
                  decoration: BoxDecoration(
                    border: Border.all(color: Colors.cyan, width: 2),
                  ),
                  child: const Center(child: Text('Hello man')),
                ),
              ),
              Positioned(
                top: 0,
                left: 0,
                bottom: 0,
                width: 80,
                child: _icon(Icons.arrow_back_ios_new),
              ),
              Positioned(
                top: 0,
                right: 0,
                width: 80,
                bottom: 0,
                child: _icon(Icons.arrow_forward_ios),
              ),
            ],
          ),
        ),
      ),
    );
  }
 
  Widget _icon(IconData icon) => Container(
        constraints: const BoxConstraints.expand(),
        decoration: BoxDecoration(
          shape: BoxShape.circle,
          color: Colors.white,
          border: Border.all(color: Colors.cyan, width: 2),
          boxShadow: [
            BoxShadow(
              color: Colors.grey[200]!,
              spreadRadius: 1,
              blurRadius: 20,
            ),
            BoxShadow(
              color: Colors.grey[300]!,
              spreadRadius: 1,
              blurRadius: 20,
            )
          ],
        ),
        child: Icon(
          icon,
          color: Colors.cyan,
        ),
      );
}
英文:

U gotta do it manually by fixing the Height. i did one for u.


class FirstScreen extends StatelessWidget {
  const FirstScreen({Key? key}) : super(key: key);
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SizedBox(
          height: 60,
          width: double.infinity,
          child: Stack(
            children: [
              Positioned(
                top: 0,
                bottom: 0,
                left: 40,
                right: 40,
                child: Container(
                  constraints: const BoxConstraints.expand(),
                  decoration: BoxDecoration(
                    border: Border.all(color: Colors.cyan, width: 2),
                  ),
                  child: const Center(child: Text('Hello man')),
                ),
              ),
              Positioned(
                top: 0,
                left: 0,
                bottom: 0,
                width: 80,
                child: _icon(Icons.arrow_back_ios_new),
              ),
              Positioned(
                top: 0,
                right: 0,
                width: 80,
                bottom: 0,
                child: _icon(Icons.arrow_forward_ios),
              ),
            ],
          ),
        ),
      ),
    );
  }
 
  Widget _icon(IconData icon) => Container(
        constraints: const BoxConstraints.expand(),
        decoration: BoxDecoration(
          shape: BoxShape.circle,
          color: Colors.white,
          border: Border.all(color: Colors.cyan, width: 2),
          boxShadow: [
            BoxShadow(
              color: Colors.grey[200]!,
              spreadRadius: 1,
              blurRadius: 20,
            ),
            BoxShadow(
              color: Colors.grey[300]!,
              spreadRadius: 1,
              blurRadius: 20,
            )
          ],
        ),
        child: Icon(
          icon,
          color: Colors.cyan,
        ),
      );
}

huangapple
  • 本文由 发表于 2023年2月16日 19:21:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471530.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定