简体   繁体   English

如何使用 flutter 创建此搜索栏和图标栏 UI(带有主页、搜索、购物车、个人资料的图标)

[英]how to create this search bar and below icon bar UI (icons with home, search, cart, profile) using flutter

want to add the bottom search bar and bottom icon bar using flutter in my home_dart page.想在我的 home_dart 页面中使用 flutter 添加底部搜索栏和底部图标栏。 can someone help me, please?有人能帮助我吗? already add 3 cards to the page.已经在页面中添加了 3 张卡片。 how can I add a search bar and bottom icon bar as shown in the picture?如图所示,如何添加搜索栏和底部图标栏? I'm trying to create a fashion app UI.我正在尝试创建一个时尚应用程序 UI。 I'm new to flutter.我是 flutter 的新手。 if someone can help me it would be great.如果有人可以帮助我,那就太好了。

在此处输入图像描述

home_page.dart home_page.dart

import 'package:flutter/material.dart';
import 'package:fashion_app/color_filters.dart';

 class HomePage extends StatefulWidget{
  @override
    _HomePageState createState ()=> _HomePageState();


  }



class _HomePageState extends State <HomePage> {
  final double _borderRadious = 24;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Fashion store'),
      ),
      body: ListView(
        padding: const EdgeInsets.all(16),
        children: [

          buildColoredCard1(),
          buildColoredCard2(),
          buildColoredCard3()

        ],
      ),


    );
  }


  Widget buildColoredCard1() =>
      Card(
        shadowColor: Colors.red,
        elevation: 8,
        clipBehavior: Clip.antiAlias,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(24),
        ),
        child: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Colors.redAccent, Colors.red],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
          ),
          padding: EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'Colored card',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 50),
              Text(
                'This card is rounded and has a gradient',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,

                ),


              ),
            ],
          ),
        ),
      );


  Widget buildColoredCard2() =>
      Card(
        shadowColor: Colors.red,
        elevation: 8,
        clipBehavior: Clip.antiAlias,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(24),
        ),
        child: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Colors.redAccent, Colors.red],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
          ),
          padding: EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'Colored card',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 50),
              Text(
                'This card is rounded and has a gradient',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,

                ),


              ),
            ],
          ),
        ),
      );


  Widget buildColoredCard3() =>
      Card(
        shadowColor: Colors.red,
        elevation: 8,
        clipBehavior: Clip.antiAlias,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(24),
        ),
        child: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Colors.redAccent, Colors.red],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
            ),
          ),
          padding: EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                'Colored card',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 50),
              Text(
                'This card is rounded and has a gradient',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white,

                ),


              ),
            ],
          ),
        ),
      );

}

here I have add the bottom navigation bar but it throws the following error again.在这里我添加了底部导航栏,但它再次引发以下错误。

在此处输入图像描述

home_page.dart home_page.dart

import 'package:flutter/material.dart';
    import 'package:fashion_app/color_filters.dart';
    
     class HomePage extends StatefulWidget{
      @override
        _HomePageState createState ()=> _HomePageState();
    
    
      }
    
    
    
    class _HomePageState extends State <HomePage> {
      final double _borderRadious = 24;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('Fashion store'),
          ),
          body: ListView(
            padding: const EdgeInsets.all(16),
            children: [
    
              buildColoredCard1(),
              buildColoredCard2(),
              buildColoredCard3()
    
            ],
          ),
    
    
        );
      }
    
    
      Widget buildColoredCard1() =>
          Card(
    
            shadowColor: Colors.red,
            elevation: 8,
            clipBehavior: Clip.antiAlias,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(24),
            ),
            child: Container(
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [Colors.redAccent, Colors.red],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                ),
              ),
              padding: EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    'Colored card',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  const SizedBox(height: 50),
                  Text(
                    'This card is rounded and has a gradient',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
    
                    ),
    
    
                  ),
                ],
              ),
            ),
          );
    
    
      Widget buildColoredCard2() =>
          Card(
            shadowColor: Colors.red,
            elevation: 8,
            clipBehavior: Clip.antiAlias,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(24),
            ),
            child: Container(
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [Colors.redAccent, Colors.red],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                ),
              ),
              padding: EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    'Colored card',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  const SizedBox(height: 50),
                  Text(
                    'This card is rounded and has a gradient',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
    
                    ),
    
    
                  ),
                ],
              ),
            ),
          );
    
    
      Widget buildColoredCard3() =>
          Card(
            shadowColor: Colors.red,
            elevation: 8,
            clipBehavior: Clip.antiAlias,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(24),
            ),
            child: Container(
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [Colors.redAccent, Colors.red],
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                ),
              ),
              padding: EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    'Colored card',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  const SizedBox(height: 50),
                  Text(
                    'This card is rounded and has a gradient',
                    style: TextStyle(
                      fontSize: 20,
                      color: Colors.white,
    
                    ),
    
    
                  ),
                ],
              ),
            ),
          );
    
    
      class _MyStatefulWidgetState extends State<MyStatefulWidget> {
      int _selectedIndex = 0;
      const TextStyle optionStyle =
      TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
      const List<Widget> _widgetOptions = <Widget>[
      Text(
      'Index 0: Home',
      style: optionStyle,
      ),
      Text(
      'Index 1: Business',
      style: optionStyle,
      ),
      Text(
      'Index 2: School',
      style: optionStyle,
      ),
      Text(
      'Index 3: Settings',
      style: optionStyle,
      ),
      ];
    
      void _onItemTapped(int index) {
      setState(() {
      _selectedIndex = index;
      });
      }
    
      @override
      Widget build(BuildContext context) {
      return Scaffold(
      appBar: AppBar(
      title: const Text('BottomNavigationBar Sample'),
      ),
      body: Center(
      child: _widgetOptions.elementAt(_selectedIndex),
      ),
      bottomNavigationBar: BottomNavigationBar(
      items: const <BottomNavigationBarItem>[
      BottomNavigationBarItem(
      icon: Icon(Icons.home),
      label: 'Home',
      backgroundColor: Colors.red,
      ),
      BottomNavigationBarItem(
      icon: Icon(Icons.business),
      label: 'Business',
      backgroundColor: Colors.green,
      ),
      BottomNavigationBarItem(
      icon: Icon(Icons.school),
      label: 'School',
      backgroundColor: Colors.purple,
      ),
      BottomNavigationBarItem(
      icon: Icon(Icons.settings),
      label: 'Settings',
      backgroundColor: Colors.pink,
      ),
      ],
      currentIndex: _selectedIndex,
      selectedItemColor: Colors.amber[800],
      onTap: _onItemTapped,
      ),
      );
      }
    
      }
    }
//use this method for the search and let me know if it's work

Widget buildSearchInput() => Container(
    decoration: BoxDecoration(
        color: Colors.grey[200], borderRadius: BorderRadius.circular(20)),
    child: Padding(
      padding: const EdgeInsets.only(left: 10.0, right: 20),
      child: Row(
        children: [
          Icon(
            Icons.search,
            size: 30,
            color: Colors.grey,
          ),
          Flexible(
            child: TextField(
              decoration: InputDecoration(border: InputBorder.none),
            ),
          ),
        ],
      ),
    ),
  );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM