小编mmc*_*cib的帖子

Flutter - cubit - 改变肘内的布尔值

我想更改肘部的布尔值,但我不知道该怎么做。

我想要实现的是,例如: if (以立方位存储的布尔值为 true) "show widget A" : "show widget B"

我的代码:

class ChangeBoolCubit extends Cubit<bool> {
  ChangeBoolCubit() : super(false);

  bool one = false;
  bool two = true;

  void changeValue(bool booleanToChange) {
    booleanToChange = !state;
    emit(booleanToChange);
  }
}
Run Code Online (Sandbox Code Playgroud)

看法:

class BoolView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Changing Bool')),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Center(
            child: BlocBuilder<ChangeBoolCubit, bool>(
              builder: (context, state) {
                return (ChangeBoolCubit().one)
                    ? Text('TRUE: ${ChangeBoolCubit().one}')
                    : Text('FALSE: …
Run Code Online (Sandbox Code Playgroud)

flutter bloc flutter-state cubit flutter-cubit

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

仅针对一种尺寸的屏幕浮动 bootstrap4

在引导程序 4 中,我想为按钮设置“float-right”,但只为 .col-sm-* 设置其余部分我使用偏移量,一切正常,但是这个宽度按钮太长而无法偏移它,但我不想改变它的大小。

这可能吗,如果是的话,我该怎么做。

html web-frameworks web-frontend twitter-bootstrap bootstrap-4

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