小编gee*_*ano的帖子

How to create sticky shop button animation in Flutter?

How can I create this sticky buy button animation of Adidas app in Flutter. I have tried to use a scroll controller to listen for the position of user and then use an animated container but it is of no use since I have to define my scroll controller in my initstate while the height of my containers are relative to my device's height. here is the link of video for the animation: https://drive.google.com/file/d/1TzIUBr6abRQI87xAVu4NOPG67aftzceK/view?usp=sharing

this is what the widget tree …

dart flutter

9
推荐指数
1
解决办法
220
查看次数

颤振构建失败。Android依赖项'androidx.core:core'对于编译(1.0.0)和运行时(1.0.1)类路径具有不同的版本

我正在尝试构建我的flutter应用程序,但它给出了以下错误:

Android依赖项“ androidx.core:core”对于编译(1.0.0)和运行时(1.0.1)类路径具有不同的版本。您应该通过DependencyResolution手动设置相同的版本

这是我的android / build.gradle文件:

buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
    project.configurations.all {
    resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "28.0.0"
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

android dart flutter

8
推荐指数
2
解决办法
4764
查看次数

如何防止颤动 showBottomSheet 通过向下拖动被解雇?

我在颤动中使用 showBottomSheet 来显示持久的底部工作表。如何防止通过向下拖动来消除颤动 showBottomSheet?我在下面添加了我的代码。您可以放置​​一个 rawmaterialbutton 并使用 onpressed 调用此函数。

  void itemChooser(
      {int currentItemCount, String name, callBack, BuildContext context}) {
    int chosen = 0;
    showBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return Container(
              height: 500,
              color: Colors.white,
              );
        });
  }
Run Code Online (Sandbox Code Playgroud)

dart flutter

7
推荐指数
2
解决办法
3830
查看次数

如何在 GridView flutter 中获取小部件的偏移量

我正在尝试向 GridView 内的 Inkwell Widget 添加爆炸效果,但我需要找到它的偏移量,到目前为止我已经尝试过:

GridView.builder(
  itemCount: 10,
  itemBuilder: (ctx, ind) {
    return InkWell(
      onTap: () async {
        try {
          final RenderBox box = ctx.findRenderObject();
          Offset position = box.localToGlobal(Offset.zero,
            ancestor: context.findRenderObject()
          );
          double x = position.dx;
          double y = position.dy;
          double w = box.size.width;
          Future.delayed(Duration(milliseconds: 100)).then(
            (_) => _particleField.lineExplosion(x, y, w)
          );
        } catch (e) {
          print(e);
        }
      },
      child: Center(
        child: Text("${ind + 1},000,000")
      ),  
    );
  },
  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
    crossAxisCount: 2, 
    childAspectRatio: 3
  ),
)
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

“RenderSliv​​erGrid”类型不是“RenderBox”类型的子类型

dart flutter

6
推荐指数
1
解决办法
1686
查看次数

flutter 运行失败:配置项目“:shared_preferences”时出现问题

我正在使用 flutter 1.2,在我向其中添加共享首选项包之前,我的项目已成功运行。 shared_preferences: ^0.5.1+2.我在添加它之后使用,flutter run命令会创建此错误:

  • 运行 Gradle 时出错:ProcessException:进程“/home//Desktop/projects/fycx/android/gradlew”异常退出:启动 Gradle 守护进程,无法重用 1 个繁忙的守护进程,请使用 --status 了解详细信息

配置项目:shared_preferences

项目评估失败,包括 afterEvaluate {} 中的错误。使用 --stacktrace 运行以获取 afterEvaluate {} 错误的详细信息。

失败:构建失败并出现异常。

gradle sharedpreferences dart flutter

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

super和Key在颤振中起什么作用?

飞镖类中超级关键字和关键词做什么?下面的代码是一个示例:

class CardTitle extends StatelessWidget {
  final String title;

  const CardTitle(this.title, **{Key key}**) : **super(key: key)**;
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
2
解决办法
2089
查看次数

颤动:未处理的异常:错误状态:调用关闭后无法添加新事件

我正在尝试使用bloc模式来管理来自API的数据,并将其显示在我的小部件中。我能够从API提取数据并对其进行处理并显示,但我使用的是底部导航栏,当我更改选项卡并转到上一个选项卡时,它将返回此错误:

未处理的异常:错误状态:调用close后无法添加新事件。

我知道这是因为我正在关闭流,然后尝试对其进行添加,但是我不知道如何解决它,因为不处理publishsubject将导致memory leak。这是我的UI代码:

class CategoryPage extends StatefulWidget {
  @override
  _CategoryPageState createState() => _CategoryPageState();
}

class _CategoryPageState extends State<CategoryPage> {
  @override
  void initState() {
    serviceBloc.getAllServices();
    super.initState();
  }

  @override
  void dispose() {
    serviceBloc.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: serviceBloc.allServices,
      builder: (context, AsyncSnapshot<ServiceModel> snapshot) {
        if (snapshot.hasData) {
          return _homeBody(context, snapshot);
        }
        if (snapshot.hasError) {
          return Center(
            child: Text('Failed to load data'),
          );
        }
        return CircularProgressIndicator();
      },
    );
  }
}

_homeBody(BuildContext context, AsyncSnapshot<ServiceModel> …
Run Code Online (Sandbox Code Playgroud)

dart flutter bloc

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

flutter - bloc - 如何在我的 Ui 中使用 FutureBuilder 来正确实现 Bloc 架构

我是 flutter 和 Bloc 架构的新手,我正在尝试将 Bloc 用于我的登录功能。我正在尝试调用我的 Bloc 文件中的函数,但我不知道该怎么做。如果您能帮我看看我在使用 Bloc 时是否还有其他问题,我也会很高兴。这是我的 Ui 的代码:

MaterialButton(
                      color: Colors.deepPurple,
                      minWidth: screenAwareSize(500, context),
                      onPressed: () {
                        _submitForm(authBloc, user, pass);
                      },
 void _submitForm(AuthBloc authBloc, String user, String pass) async {
    formKey.currentState.save();
    if (formKey.currentState.validate()) {
      var response = await authBloc.login(user, pass);
//when I print(response) it shows null


    }
  }
Run Code Online (Sandbox Code Playgroud)

这是我的集团班级:

class AuthBloc extends MainBloc {
  final Repo _repo = Repo();
  PublishSubject<Future<UserModel>> _authController = new PublishSubject<Future<UserModel>>();
  Observable<Future<UserModel>> get auth => _authController.stream;
  login(String user, String pass) async { …
Run Code Online (Sandbox Code Playgroud)

dart flutter bloc

3
推荐指数
1
解决办法
3588
查看次数

如何将列表视图放在SingleChildScrollView中,但防止它们分开滚动?

我有一个像这样的小部件树:

SingleChildScrollView
   Column
     Container
       ListView(or GridView)
Run Code Online (Sandbox Code Playgroud)

问题是当我的小部件树如上时,它给我错误

需要油漆

所以我像这样更改我的小部件树:

Column
     Container
       ListView(or GridView)
Run Code Online (Sandbox Code Playgroud)

但是在这种情况下,ListView或GridView部分会单独滚动,而我希望整个窗口小部件树都可以滚动。您认为我如何实现?

dart flutter

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

标签 统计

dart ×9

flutter ×9

bloc ×2

android ×1

gradle ×1

sharedpreferences ×1