代码

import 'package:flutter/material.dart';
class InputBoxContainer extends StatefulWidget {
  InputBoxContainer({Key key, this.onChange, this.icon}) : super(key: key);

  final onChange;
  final IconData icon;

  @override
  State<StatefulWidget> createState() {
    return InputBoxContainerBuilder();
  }
}

class InputBoxContainerBuilder extends State<InputBoxContainer> {
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 2.0, bottom: 2.0),
      margin: EdgeInsets.only(bottom: 30.0),
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(100.0),
          border: Border.all(
              width: 1.0,
              style: BorderStyle.solid,
              color: Color.fromRGBO(0, 0, 0, 0.1))),
      child: TextField(
        onChanged: widget.onChange,
        decoration: InputDecoration(
            border: InputBorder.none,
            icon: widget.icon != null ? Icon(widget.icon) : null),
      ),
    );
  }
}

预览

在这里插入图片描述

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐