小编Ale*_*Ale的帖子

当应用程序进入前台时 React Native 强制组件刷新

我的应用程序显示一些文本。Component当字体大小通过设置 --> 辅助功能 --> 字体大小更改时,我需要重新渲染:

在此处输入图片说明

所以基本上这是se序列:

  • 应用程序已打开(前台)。
  • 用户打开电话设置,以便应用程序进入前台(未完全关闭)。
  • 用户通过设置 --> 辅助功能 --> 字体大小来更改字体大小。
  • 用户关闭设置并打开应用程序再次进入前台。

此时我需要重新加载应用程序,因为有些Components需要调整。

我正在使用react-native-device-info来获取字体大小,const fontScale = DeviceInfo.getFontScale();但在应用程序完全关闭和打开之前,它的值不会更新。

有任何想法吗?

accessibility font-scaling react-native react-native-device-info react-hooks

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

来自另一个屏幕的颤振更新状态

我有两个屏幕。在第一个中,有一个ListView. 在第一个元素中,我显示了变量的值selectedObject

ListTile按下 时,会打开第二个屏幕。我想selectedObject在从第二个屏幕返回后更新该值。

我需要分配的值resultselectedObject变量。

我想我必须调用该setState方法,但我不知道如何调用。

这是我的代码:

class _FilterTaskState extends State<FilterTask> {
List taskList;

String selectedObject = "initial value";

@override
Widget build(BuildContext context) {
return new Scaffold(
  appBar: _buildAppBar(context, "AppBar Title"),
  body: Center(
    child: new ListView(
      children: <Widget>[
         new ListTile(
          leading: new Icon(Icons.home, color: Colors.black),
          title: new Text("Selected Object", style: styleTitle),
          subtitle: new Text(selectedObject),
          trailing: new Icon(Icons.play_arrow, color: Colors.black),
          onTap: () => _navigateToFilterObject(context),
        ),

        ...

      ], …
Run Code Online (Sandbox Code Playgroud)

setstate flutter

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

颤动的桌子结构

我想得到这个结构:

-----------------------------------------------------------------------------------
item 1                                 item 2
item 3                                 item 4
-----------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

基本上我需要一个Table带2 columns的2 rows,每个2 column,但这是我得到的效果:

在此输入图像描述

我的代码:

new Container(
          decoration: new BoxDecoration(color: Colors.grey),
          child: new Row(
            children: <Widget>[

              new Column(
                children: <Widget>[
                  new Container(
                    decoration: new BoxDecoration(color: Colors.red),
                    child: new Text("item 1"),
                  ),
                  new Container(
                    decoration: new BoxDecoration(color: Colors.amber),
                    child: new Text("item 3"),
                  ),
                ],
              ),

              new Column(
                children: <Widget>[
                  new Container(
                    decoration: new BoxDecoration(color: Colors.green),
                    child: new Text("item 2"),
                  ),
                  new Container(
                    decoration: new BoxDecoration(color: …
Run Code Online (Sandbox Code Playgroud)

tabular flutter flutter-layout

3
推荐指数
2
解决办法
8522
查看次数

AppBar下方的Flutter Drawer

我已经Drawer在我的Flutter应用中实现了。

闭馆时间Drawer

在此处输入图片说明

开业时间Drawer

在此处输入图片说明

如您所见,Drawer在的上方Appbar。在上启动应用程序之前Flutter,我们有一个本机Android应用程序,该应用程序Drawer过去看起来像这样:

闭馆时间Drawer

在此处输入图片说明

开业时间Drawer

在此处输入图片说明

这是我的代码:

class MyDrawer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return _buildDrawer(context);
  }
}

Widget _buildDrawer(BuildContext context) {
  return new Drawer(
    child: new ListView(
      children: <Widget>[
        _buildDrawerItem(context, EnumDrawerItem.PROJECT_SELECTION, Icons.home, Colors.transparent),
        new Divider(height: 20.0),
        _buildDrawerItem(context, EnumDrawerItem.TASK_LIST, Icons.home, Colors.transparent),
        new Divider(),
        _buildDrawerItem(context, EnumDrawerItem.GUIDED_TASKS, Icons.home, Colors.transparent),
        new Divider(),
        _buildDrawerItem(context, EnumDrawerItem.PHOTOS, Icons.home, Colors.transparent),
        new Divider(), …
Run Code Online (Sandbox Code Playgroud)

appbar drawer flutter flutter-layout

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