小编Gau*_*mar的帖子

如何在hive对象中编写自定义类对象?

在 flutter 中使用 hive 时,我Profile profile在 hive 对象中使用了自定义类对象。

因此,最初,我将自定义类对象(Profile profile)设置为null在 Hive 框中添加时。

以下是我的 Hive 课程:

import 'dart:convert';
import 'package:hive/hive.dart';
import 'package:lpa_exam/src/model/listofexams.dart';
import 'package:lpa_exam/src/model/profile.dart';
part 'hiveprofile.g.dart';

@HiveType()
class PersonModel extends HiveObject{
  @HiveField(0)
  String language;

  @HiveField(1)
  String examName;

  @HiveField(2)
  int examId;

  @HiveField(3)
  Profile profile;

  @HiveField(4)
  ListExam listexam;

  @override
  String toString() {
    return jsonEncode({
      'language': this.language,
      'examName': this.examName,
      'examId': this.examId,
      'profile': this.profile,
      'listexam': this.listexam
    });
  }

  PersonModel(
      this.language, this.examName, this.examId, this.profile, this.listexam);
}
Run Code Online (Sandbox Code Playgroud)

可供参考的型材类别:

class Profile { …
Run Code Online (Sandbox Code Playgroud)

flutter

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

如何在颤动中为 ClipOval 添加阴影?

作为初学者,我一直在尝试制作一个新的应用程序。所以,给事物添加阴影对我来说是全新的。

所以,以下是我的代码:

Container(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              ClipOval(
                child: Material(
                  color: Colors.white, // button color
                  child: InkWell(
                    // splashColor: Colors.red, // inkwell color
                    child: SizedBox(
                        width: 46, height: 46, child: Icon(Icons.menu,color: Colors.red,),),
                    onTap: () {},
                  ),
                ),
              ),

            ],
          ),
        ),
Run Code Online (Sandbox Code Playgroud)

以下是模拟:

嘲笑

flutter flutter-layout

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

如何更改charts_flutter中条形图的条形宽度?

尝试用于charts_flutter条形图,但找不到减少简单条形图中条形宽度的属性。

以下是我的模拟: 图表

另外,不知道如何:

-在此包中添加以下索引

- 在条形内添加值,如模拟中所示。

以下是我的代码:

class HiddenTicksAndLabelsAxis extends StatelessWidget {
  final List<charts.Series> seriesList;
  final bool animate;

  HiddenTicksAndLabelsAxis(this.seriesList, {this.animate});

  factory HiddenTicksAndLabelsAxis.withSampleData() {
    return new HiddenTicksAndLabelsAxis(
      _createSampleData(),
      // Disable animations for image tests.
      animate: true,
    );
  }


  @override
  Widget build(BuildContext context) {
    return new charts.BarChart(
      seriesList,
      animate: animate,

      /// Assign a custom style for the measure axis.
      ///
      /// The NoneRenderSpec can still draw an axis line with
      /// showAxisLine=true.
      primaryMeasureAxis:
          new charts.NumericAxisSpec(renderSpec: new charts.NoneRenderSpec()),

      /// This is …
Run Code Online (Sandbox Code Playgroud)

charts flutter flutter-layout

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

如何在 react-bootstrap 中打开多个手风琴选项卡?

如果可能,我正在尝试打开多个手风琴。目前正在使用react-bootstrap图书馆。

以下是我的实现:

<Accordion>
  {data.rows.map((item, index) => {
    return (
      <Card
        style={{
          border: "none",
          marginTop: "1em",
          borderBottom: "1px solid #f1f1f1",
        }}
      >
        <Card.Header
          style={{ background: "transparent", padding: "0.75em 0" }}
        >
          <Row>
            <Col lg="10" sm xs="9" style={{ alignSelf: "center" }}>
              <p
                className="cardtitle"
                style={{ fontWeight: "600" }}
              >
                {item.title}
              </p>
            </Col>
            <Col style={{ textAlign: "right" }} xs sm>
              {" "}
              <ContextAwareToggle eventKey={index}>
                +
              </ContextAwareToggle>
            </Col>
          </Row>
        </Card.Header>
        <Accordion.Collapse eventKey={index}>
          <Card.Body>
            <p className="cardcontent">{item.content}</p>
          </Card.Body>
        </Accordion.Collapse>
      </Card>
    );
  })}{" "}
</Accordion>

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

reactjs react-bootstrap

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

如何在flutter中更新hive对象的特定字段?

我在我的 flutter 应用程序中使用 hive 作为我的 NoSQL 本地数据库。

以下是我的 Hive 课程:

import 'dart:convert';

import 'package:hive/hive.dart';
import 'package:lpa_exam/src/model/listofexams.dart';
import 'package:lpa_exam/src/model/profile.dart';
part 'hiveprofile.g.dart';

@HiveType()
class PersonModel extends HiveObject{
  @HiveField(0)
  String language;

  @HiveField(1)
  String examName;

  @HiveField(2)
  int examId;

  @HiveField(3)
  Profile profile;

  @HiveField(4)
  ListExam listexam;

  @override
  String toString() {
    return jsonEncode({
      'language': language,
      'examName': this.examName,
      'examId': examId,
      'profile': profile,
      'listexam': listexam
    });
  }

  PersonModel(
      this.language, this.examName, this.examId, this.profile, this.listexam);
}
Run Code Online (Sandbox Code Playgroud)

所以,我的要求是在每次成功登录时我都应该更新配置文件对象。但为此,我还必须设置所有其他人。

我怎样才能只更新配置文件对象?

代码:

_personBox = Hive.openBox('personBox');
          await _personBox.then((item) {
            if (!item.isEmpty) {
              print('empty');
              item.putAt(0, PersonModel(...,..,..,..,...,..)); …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-hive

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

如何将折叠/展开图标更改为材质 TreeView 的右侧?

我正在尝试使用 Reactjs 中的材料来实现一棵树。但是,根据我的设计,折叠和展开的按钮应该在右侧。

另外,在添加这样的图标时出现错误TreeItem

<TreeItem nodeId="1" label="RSMSSB" icon={FolderIcon}>
Run Code Online (Sandbox Code Playgroud)

全码:

import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import TreeView from "@material-ui/lab/TreeView";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import ChevronRightIcon from "@material-ui/icons/ChevronRight";
import TreeItem from "@material-ui/lab/TreeItem";
import FolderIcon from '@material-ui/icons/Folder';
const useStyles = makeStyles({
  root: {
    height: 216,
    flexGrow: 1,
    maxWidth: 400
  }
});

export default function ControlledTreeView() {
  const classes = useStyles();
  const [expanded, setExpanded] = React.useState([]);

  const handleChange = (event, nodes) => {
    setExpanded(nodes);
  };

  return ( …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

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

Flutter:如何从 ExpansionPanelList 中删除高程?

我试图像小部件一样列出下拉列表,但幸运的是找到了扩展面板列表小部件来获得我想要的用户体验。

所以,我在我的颤振应用程序中使用 ExpansionPanelList,但不需要它附带的默认高程/边框阴影。

我不知道如何移除它,以便让它看起来是身体的一部分,而不是一个高架容器。

目前看起来像这样:

嘲笑

以下是我的代码:

class _PracticetestComp extends State<Practicetest> {
  var listofpracticetest;
  List<Item> _data = [
    Item(
      headerValue: 'Previous Question Papers',
      expandedValue: '',
    )
  ];


  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Color(0xffF8FDF7),
        appBar: AppBar(
          backgroundColor: Color(0xffF8FDF7), // status bar color
          brightness: Brightness.light,
          elevation: 0.0,
          leading: Container(
            margin: EdgeInsets.only(left: 17),
            child: RawMaterialButton(
              onPressed: () {
                Navigator.pushNamed(context, '/');
              },
              child: new Icon(
                Icons.keyboard_backspace,
                color: Colors.red[900],
                size: 25.0,
              ),
              shape: new CircleBorder(),
              elevation: 4.0,
              fillColor: Colors.white,
              padding: const EdgeInsets.all(5.0),
            ), …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-layout

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

如何从 withHandlers 调用另一个函数?

我正在尝试使用 package.json 在我的应用程序中实现谷歌地图react-google-maps。在地图中,我显示了多个Marker并使用过的MarkerCluster.

到目前为止,我没有任何问题,并且可以轻松地从文档中实现。但现在我想显示InfoWindow标记是否被单击。

所以,我想到制作一个函数来获取点击事件并传递markerId,这样我就可以调用 API 并获取该标记的相关数据,然后以表格方式将其放入 infowindow 中。

现在,我面临的问题是:

1) 呼叫onToggleOpen来自onMarkerClick

2)如何在infowindow对象中设置数据onMarkerClick

我面临的所有这些问题都是因为我使用 HOC ie recompose。我习惯了类实现,但尝试过函数式实现,试图使其纯粹无状态。

参考链接: https: //tomchentw.github.io/react-google-maps/#infowindow

以下是我的代码:

import React, { Component } from "react";
import Header from "./Header.js";
import Sidebar from "./Sidebar.js";
import axios from "axios";
import imgmapcluster from "./pins/iconmapcluster.png";
import user from "./pins/user1copy.png";
import { compose, withProps, withHandlers } from "recompose";
import {
  withScriptjs,
  withGoogleMap,
  GoogleMap,
  Marker,
  InfoWindow
} from …
Run Code Online (Sandbox Code Playgroud)

reactjs recompose react-google-maps

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

如何为 react-bootstrap 的活动选项卡切换 css 类?

我正在尝试向活动选项卡添加自定义样式,但不知道如何切换活动选项卡的样式类。

以下是我的代码:

import React, { useState } from "react";
import "./styles.css";
import { Container, Row, Col, Tab, Nav } from "react-bootstrap";

export default function App() {
  const [key, setKey] = useState("first");

  const ActiveStyle = {
    textAlign: "center",
    background: "white",
    borderRadius: "2em",
    padding: " 0.3em 1.5em",
    letterSpacing: "0.2em"
  };

  const inActiveStyle = {
    ...ActiveStyle,
    background: "transparent",
    "border-color": "transparent",
    color: "inherit"
  };

  return (
    <div className="App">
      <Container style={{ width: "auto" }}>
        <Tab.Container activeKey={key} onSelect={key => setKey(key)}>
          <Row style={{ padding: "1em 1em", background: …
Run Code Online (Sandbox Code Playgroud)

reactjs react-bootstrap

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

如何在颤动中单击(关闭)按钮时关闭抽屉?

如果单击抽屉右上角创建的关闭按钮,是否有关闭抽屉的方法。

模拟抽屉:

抽屉模拟

flutter flutter-layout

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