标签: flutter-layout

自定义卡形状颤振SDK

我刚开始学习Flutter,我用GridView开发了一个应用程序.GridView项目是卡.默认卡片形状为矩形,半径为4.

我知道Card Widget有shape属性,它需要ShapeBorder类.但我无法找到如何使用ShapeBorder类并在GridView中自定义我的卡.

提前致谢.

flutter flutter-layout

23
推荐指数
5
解决办法
3万
查看次数

如何在Flutter中更改状态栏颜色?

我正在尝试将状态栏颜色更改为白色...我发现这个酒吧在flutter https://pub.dartlang.org/packages/flutter_statusbarcolor ...我试图在我的dart文件(主要和其他)上使用示例代码...但是它不起作用......任何想法的家伙?

dart flutter flutter-dependencies flutter-layout

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

如何在颤动中滚动页面

我的页面代码是这样的.我需要在appbar下方滚动部分.

@override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(... ),
      body: new Stack(
        children: <Widget>[
          new Container(
            decoration: BoxDecoration(
                image: DecorationImage(...),
          new Column(children: [
            new Container(...),
            new Container(...... ),
            new Padding(
              child: SizedBox(
                child: RaisedButton(..),
            ),
            new Divider(),
            new Column(
              children: <Widget>[
                new Container(
                  child: new Row(
                    children: <Widget>[
                      new Expanded(
                        child: new Text(  ),
                      ),
                      new IconButton(
                        icon: IconButton(..),
                        onPressed: () {
                          _changed(true, "type");
                        },
                      ),
                    ],
                  ),
                ),
                visibilityPropertyType
                    ? new Container(
                        margin: EdgeInsets.all(24.0),
                        child: …
Run Code Online (Sandbox Code Playgroud)

scrollview dart flutter flutter-layout

22
推荐指数
6
解决办法
3万
查看次数

找不到方向性小部件

我正在尝试创建一个简单的布局,flutter但不断收到此错误:

以下断言被抛出构建文本("更快地交付功能",textAlign:center):找不到方向性小部件.

我认为问题可能在TextDirection类属性中,但我一直无法找到它.

这是我的代码:

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void main(){

  runApp( new MyHome());
}

class MyHome extends StatelessWidget{

  @override

  Widget build(BuildContext context) {
    // TODO: implement build
    return new Material(
      child: new Container(
        color: Colors.red,
        margin: const EdgeInsets.all(5.0),
        child: new Row(
          children: <Widget>[
            new Expanded(
              child: new Text('Deliver features faster', textAlign: TextAlign.center),
            ),
            new Expanded(
              child: new Text('Craft beautiful UIs', textAlign: TextAlign.center),
            ),
            new Expanded(
              child: new FittedBox(
                fit: BoxFit.contain, // otherwise the logo will be tiny
                child: …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout

21
推荐指数
4
解决办法
7345
查看次数

颤动:如何使按钮扩展到它的父级大小?

我正在尝试创建方形按钮,但Expanded似乎与容器的工作方式不同.以下面的代码为例

new Expanded(
 flex: 2,
   child: new Column(
     children: <Widget>[
       new Expanded(
         child:new Row(
           children: <Widget>[
             new Expanded(child: new MaterialButton(...)),
             new Expanded(child: new MaterialButton(....)),

             new Expanded(child: new Container(color: Colors.red)),
             new Expanded(child: new Container(color: Colors.green)),
           ]
         )
       )
     ],
   )
 )

 ....
Run Code Online (Sandbox Code Playgroud)

它显示两个水平扩展但不垂直的按钮.同时,容器将水平和垂直扩展.如果我执行以下操作,则会产生相同的效果:

new Expanded(
 flex: 2,
   child: new Column(
     children: <Widget>[
       new Expanded(
         child:new Column(
           children: <Widget>[
             new Expanded(child: new MaterialButton(...)),
             new Expanded(child: new MaterialButton(....)),

             new Expanded(child: new Container(color: Colors.red)),
             new Expanded(child: new Container(color: Colors.green)),
           ]
         )
       )
     ],
   ) …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout

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

如何检测Flutter中布局的方向变化?

如何找到方向是Flutter中的肖像或风景

if(portrait){
  return ListView.builder()
}else{
  return GridView.count()
}
Run Code Online (Sandbox Code Playgroud)

orientation dart flutter flutter-layout

21
推荐指数
4
解决办法
7418
查看次数

如何只在容器的特定一侧添加阴影?

我正在尝试使用 BoxDecoration 小部件中的 boxShadow 参数仅向容器小部件的右侧添加阴影。

new Container(
  decoration: BoxDecoration(
    color: Colors.grey.withOpacity(0.5),
    boxShadow: [
      BoxShadow(
        blurRadius: 5.0
      ),
    ],
  ),
),
Run Code Online (Sandbox Code Playgroud)

此代码有效,但会在容器的每个可能的一侧添加阴影。我希望它只在右侧。

dart box-shadow flutter flutter-layout

21
推荐指数
4
解决办法
7593
查看次数

Flutter 如何在 Listview.builder、SingleChildScrollView 等可滚动小部件中隐藏滚动条(拇指)

SingleChildScrollView有没有办法从 a和中删除滚动条Listview.builder?最新更新后,滚动时会自动出现(平台 Windows)。

我尝试过这个解决方案:

 NotificationListener<ScrollNotification>(
     onNotification: (_) => true,
     child: ...,
    );

Run Code Online (Sandbox Code Playgroud)

并且还尝试使用 isAlwaysShown 和控制器将我的小部件树包装在滚动条小部件中,但这两种变体都不起作用。

还在

scrollbar flutter flutter-layout

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

颤振错误:此小部件已被卸载,因此状态不再具有上下文(并且应被视为已失效)

当我在我的手机号码错误时单击“登录”按钮时,然后打开一个错误对话框,然后当我在对话框上单击“确定”时,我收到此错误。

我收到这条消息

该小部件已被卸载,因此状态不再具有上下文(并且应被视为已失效)

考虑在“dispose”期间取消任何活动的工作,或使用“mounted” getter 来确定状态是否仍处于活动状态。

class _LoginPageState extends State<LoginPage> {
  final GlobalKey<FormState> _formKey = GlobalKey();

  TextEditingController _mobileController = new TextEditingController();
  // TextEditingController _nameController = new TextEditingController();
  // TextEditingController _emailController = new TextEditingController();
  TextEditingController _passwordController = new TextEditingController();

  Map<String, String> _authData = {
    'user_name': '',
    'user_email': '',
    'username': '',
    'password': ''
  };

  Future _submit() async {
    print('aa' + _authData['username']);
    if (!_formKey.currentState.validate()) {
   

      return;
    }
    _formKey.currentState.save();
    try {
      await Provider.of<Auth>(context, listen: false).login(
          _authData['user_name'],
          _authData['user_email'],
          _authData['username'],
          _authData['password']);


      print('authData_username' + _authData['username']);
      print('authData_password' + …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-test flutter-dependencies flutter-layout

21
推荐指数
3
解决办法
6万
查看次数

Flutter 如何在单击 TextField 时始终隐藏键盘但保持焦点(保持显示光标)

我无法控制键盘显示或隐藏,在我的项目中,我需要始终隐藏键盘但保持专注以显示我的自定义键盘(小部件)。

这是我想要的

这是我的问题

flutter flutter-layout

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