小编Dvd*_*ibi的帖子

如何在段落中加粗(或格式化)一段文本?

如何使用不同格式的文本行?

例如:

你好世界

dart flutter

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

如何根据父级的大小布局小部件?

假设您有一个可能具有可变大小的父窗口小部件.

例如:

var container = new Container(
   height: 200.0, // Imagine this might change
   width: 200.0, // Imagine this might change
   // Imagine content in this container will 
   // depend on the parent container
   child: new Container(), 
);
Run Code Online (Sandbox Code Playgroud)

也许你想让父容器的子进程根据它给出的大小来呈现不同的东西.

想想响应式设计断点,如果宽度超过X则使用此布局,如果宽度在X下使用该布局.

在Flutter中做到这一点的最佳方法是什么?

dart flutter

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

如何在具有颤动的可滚动视图中使用具有可变高度内容的TabView?

我有一个嵌套在Block中TabBarTabBarView.这是因为TabBarView内部的内容是动态的,并且直到运行时才知道内容的高度.

我无法将Block嵌套在TabBarView中,因为TabBar之前的内容应该与TabBarView内容一起滚动.

图:

布局图

码:

new DefaultTabController(
  length: 3,
  child: new Block(
    children: [
      new Container(
        height: 200.0,
        decoration: new BoxDecoration(
          backgroundColor: Colors.blue[500],
        ),
      ),
      new TabBar(
        tabs: <Widget>[
          new Tab(text: '1'),
          new Tab(text: '2'),
          new Tab(text: '3'),
        ],
      ),
      new TabBarView(
        children: [
          new Text('one'),
          new Text('two'),
          new Text('three'),
        ],
      ),
    ],
  )
);
Run Code Online (Sandbox Code Playgroud)

但是,TabBarView的视口不受约束,需要具有有界高度约束的祖先窗口小部件.不幸的是,Block不具有有界高度,因为它具有可滚动性.

运行布局时收到此错误:

??? EXCEPTION CAUGHT BY RENDERING LIBRARY    ??????????????????????????????????????????????????????????
I/flutter (28715): The following assertion was thrown during   performLayout():
I/flutter (28715): …
Run Code Online (Sandbox Code Playgroud)

dart flutter

10
推荐指数
2
解决办法
1864
查看次数

如何使用 AnimatedContainer 进行动画变换(例如缩放)

我希望使用AnimatedContainertransform属性为容器的比例设置动画;然而,规模没有被过渡,直接从开始跳到结束。

代码片段:

var container = new AnimatedContainer(
  duration: const Duration(milliseconds: 200),
  width: 50.0,
  height: 50.0,
  // selected is a bool that will be toggled
  transform: selected ? new Matrix4.identity() : new Matrix4.identity().scaled(0.2,0.2),
  decoration: new BoxDecoration(
    shape: BoxShape.circle,
    backgroundColor: Colors.blue[500],
  ),
  child: new Center(
    child: new Icon(
      Icons.check,
      color: Colors.white,
    ),
  )
);
Run Code Online (Sandbox Code Playgroud)

关于发生了什么的任何见解?

dart flutter

10
推荐指数
1
解决办法
7993
查看次数

以编程方式专注于InputField并打开键盘

我遇到一种情况,我需要以编程方式专注于InputField(例如响应按钮按下)。

我正在使用Focus.moveTo函数;但是,即使InputField被聚焦(出现闪烁的光标),键盘也不会被抬起。

似乎最好的解决方案是在_InputFieldState中调用RequestKeyboard()函数,但这是私有的。

做到这一点的最佳方法是什么?

这是显示工作流程的代码示例:

class InputFieldWrapper extends StatefulWidget {

  @override
  _InputFieldWrapperState createState() => new _InputFieldWrapperState();
}


class _InputFieldWrapperState extends State<InputFieldWrapper> {

  InputValue _currentInput = new InputValue(text: 'hello');

  // GlobalKey for the InputField so we can focus on it
  GlobalKey<EditableTextState> _inputKey = new GlobalKey<EditableTextState>();

  @override
  Widget build(BuildContext context) {
    return new Column(
      children: [
        // Button that should focus on the InputField when pressed
        new IconButton(
          icon: new Icon(Icons.message),
          onPressed: () { …
Run Code Online (Sandbox Code Playgroud)

dart flutter

5
推荐指数
1
解决办法
562
查看次数

标签 统计

dart ×5

flutter ×5