相关疑难解决方法(0)

缠绕文字

随着文本的增长,我想要包装文本.我搜索并尝试用几乎所有东西包裹,但仍然文本保持一行并从屏幕溢出.有谁知道如何实现这一目标?任何帮助都非常感谢!

Positioned(
    left: position.dx,
    top: position.dy,
    child: new Draggable(
      data: widget.index,
      onDragStarted: widget.setDragging,
      onDraggableCanceled: (velocity, offset) {
        setState(() {
          position = offset;
          widget.secondCallback(offset, widget.index);
          widget.endDragging();
        });
      },
      child: new GestureDetector(
        onTap: () {
          widget.callback(widget.caption, widget.index);
        },
        child: new Text(
            widget.caption.caption,
            style: new TextStyle(
              color: widget.caption.color,
              fontSize: widget.caption.fontSize,
            ),
          ),
      ),
      feedback: new Material(
        type: MaterialType.transparency,
        child: new Text(
          widget.caption.caption,
          style: new TextStyle(
              color: widget.caption.color,
              fontSize: widget.caption.fontSize),
          softWrap: true,
        ),
      ),
    ));
Run Code Online (Sandbox Code Playgroud)

dart flutter

28
推荐指数
9
解决办法
5万
查看次数

在 flutter 中下拉 ListView

DropDownButton每当我ListView.Builder从下拉列表中选择时,它都会给出更改值,但不会反映在用户界面上。

 List _warranty = ["NONE","1 YEAR", "2 YEAR"];
 List<DropdownMenuItem<String>> getDropDownWarranty() {
      List<DropdownMenuItem<String>> items = new List();
      for (String str in _warranty) {
        items.add(new DropdownMenuItem(
            value: str,
            child: new Text(
              str,
              style: TextStyle(color: Colors.white, fontFamily: 'semibold'),
            )));
      }
      return items;
    }
Run Code Online (Sandbox Code Playgroud)

这是我的ListView项目小部件

  Widget item(AsyncSnapshot<CartBean> snapshot, int index) {
      String _current = "";
      return Column(
        children: <Widget>[
          Container(
            height: 40,
            decoration: BoxDecoration(color: MyColors.cartback),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.end,
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Container(
                  width: SizeConfig.screenWidth / …
Run Code Online (Sandbox Code Playgroud)

android ios dart flutter

4
推荐指数
1
解决办法
1万
查看次数

在颤动中创建自定义下拉列表 - 或者如何将自定义下拉选项放在其他所有内容之上的图层中

我正在寻找一种创建自定义下拉列表的方法,以便我可以自己设置样式。

我遇到了这个似乎非常有用的答案

/sf/answers/4421605541/

问题是如果容器小于下拉菜单,flutter 会抱怨像素溢出。我怎样才能让这个下拉菜单位于页面中其他元素的顶部,所以我没有收到这个警告?或者是否有另一种方法可以在没有此问题的情况下重新创建自定义下拉列表?

我找到的所有答案都是关于内置 DropdownButton

下面,上面链接的答案,带有版本


首先,创建一个名为 的 dart 文件drop_list_model.dart

import 'package:flutter/material.dart';

class DropListModel {
  DropListModel(this.listOptionItems);

  final List<OptionItem> listOptionItems;
}

class OptionItem {
  final String id;
  final String title;

  OptionItem({@required this.id, @required this.title});
}
Run Code Online (Sandbox Code Playgroud)

接下来,创建文件file select_drop_list.dart

import 'package:flutter/material.dart';
import 'package:time_keeping/model/drop_list_model.dart';
import 'package:time_keeping/widgets/src/core_internal.dart';

class SelectDropList extends StatefulWidget {
  final OptionItem itemSelected;
  final DropListModel dropListModel;
  final Function(OptionItem optionItem) onOptionSelected;

  SelectDropList(this.itemSelected, this.dropListModel, this.onOptionSelected);

  @override
  _SelectDropListState createState() => _SelectDropListState(itemSelected, dropListModel);
}

class _SelectDropListState extends State<SelectDropList> with SingleTickerProviderStateMixin { …
Run Code Online (Sandbox Code Playgroud)

drop-down-menu flutter flutter-layout

4
推荐指数
3
解决办法
6774
查看次数

Flutter 中使用图标的下拉列表

我想在 Flutter 中为特定图标实现下拉列表,并在 AppBar 中对其应用 GestureDetector。它的代码是,

AppBar(
   actions: <Widget>[
      Padding(
        padding: const EdgeInsets.fromLTRB(4.0, 4.0, 0, 4.0),
        child: Image.network(
            "Some Image Url"),
      ),
   GestureDetector(
        onTap: () {
//       I want to implement the Dropdown List here.
        },
        child: Padding(
          padding: const EdgeInsets.all(0.0),
          child: Icon(Icons.arrow_drop_down),
        ),
      ),
     ],
    )
Run Code Online (Sandbox Code Playgroud)

icons appbar dart drop-down-menu flutter

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

flutter ×4

dart ×3

drop-down-menu ×2

android ×1

appbar ×1

flutter-layout ×1

icons ×1

ios ×1