Почему не работает lasteight? проблема в Failed assertion: line 124 pos 16:

  void shared() async {
    await SharedPreferences.getInstance().then((onValue) {
      if (onValue.getString("Start") != null) {
        DateTime st = DateTime.parse(onValue.getString("Start"));
        double wate = onValue.getDouble("Water") != null
            ? onValue.getDouble("Water")
            : 0.0;
        setState(() {
          strt = st;
          water = (wate / 0.125);
        });
      }
      lastWeight = onValue.getDouble("Weight");
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      resizeToAvoidBottomPadding: false,
      backgroundColor: kMainColor7,
      appBar: AppBar(
        backgroundColor: kMainColor7,
        elevation: 0,
        centerTitle: true,
        title: Text(
          'Summary',
          style: kBodyTextStyle,
        ),
      ),
      body: ListView(
        shrinkWrap: true,
        children: <Widget>[
          Expanded(
            child: ReusableCard(
              colour: kMainColor12,
              cardChild: Column(
                children: <Widget>[
                  SizedBox(
                    height: 20,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.end,
                    children: <Widget>[
                      Icon(FontAwesomeIcons.stopwatch, color: Colors.white),
                      SizedBox(
                        width: 5,
                      ),
                      Text(
                        '${end.difference(strt).inHours} hours ${end.difference(strt).inMinutes.remainder(60)} minutes ',
                        style: kLabelTextStyle2,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Container(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: <Widget>[
                        Column(
                          children: <Widget>[
                            Column(
                              children: <Widget>[
                                Text(
                                  'Started',
                                  style: kSaveTimeLabelTextStyle,
                                ),
                                SizedBox(
                                  height: 5,
                                ),
                                Text(
                                  DateFormat.E().add_jm().format(strt),
                                  style: kSaveTimeDateFormatTextStyle,
                                ),
                              ],
                            ),
                            InkWell(
                              onTap: () {
                                DatePicker.showDateTimePicker(context,
                                    showTitleActions: true,
                                    onConfirm: (date) async {
                                  setState(() {});
                                  strt = date;
                                }, currentTime: strt, locale: LocaleType.en);
                              },
                              child: Container(
                                width: 90,
                                height: 40,
                                child: Card(
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(20),
                                  ),
                                  color: kMainColor1,
                                  elevation: 5,
                                  child: Center(
                                      child: Text('Edit',
                                          style: kSaveTimeButtonTextStyle)),
                                ),
                              ),
                            ),
                          ],
                        ),
                        Column(
                          children: <Widget>[
                            Column(
                              children: <Widget>[
                                Text(
                                  'Ended',
                                  style: kSaveTimeLabelTextStyle,
                                ),
                                SizedBox(
                                  height: 5,
                                ),
                                Text(
                                  DateFormat.E().add_jm().format(end),
                                  style: kSaveTimeDateFormatTextStyle,
                                ),
                              ],
                            ),
                            InkWell(
                              onTap: () {
                                DatePicker.showDateTimePicker(context,
                                    showTitleActions: true,
                                    onConfirm: (date) async {
                                  setState(() {});
                                  end = date;
                                }, currentTime: end, locale: LocaleType.en);
                              },
                              child: Container(
//                      margin: EdgeInsets.fromLTRB(150, 10, 150, 10),
                                width: 90,
                                height: 40,
                                child: Card(
                                  shape: RoundedRectangleBorder(
                                    borderRadius: BorderRadius.circular(40),
                                  ),
                                  color: kMainColor1,
                                  elevation: 5,
                                  child: Center(
                                      child: Text('Edit',
                                          style: kSaveTimeButtonTextStyle)),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ],
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                ],
              ),
            ),
          ),
          Row(
            children: <Widget>[
              Expanded(
                  child: ReusableCard(
                colour: kMainColor12,
                cardChild: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      height: 20,
                    ),
                    Text(
                      'Weight',
                      style: kLabelTextStyle2,
                    ),
                    InkWell(
                      borderRadius: BorderRadius.circular(20.0),
                      onTap: () {
                        showModalBottomSheet(
                            context: context,
                            builder: (context) {
                              return Container(
                                color: Color(0xFF090a0c),
                                child: Container(
                                  height:
                                      MediaQuery.of(context).size.height / 2,
                                  decoration: BoxDecoration(
                                    color: Colors.white,
                                    borderRadius: BorderRadius.only(
                                        topLeft: Radius.circular(20),
                                        topRight: Radius.circular(20)),
                                  ),
                                  child: Container(
                                    margin: EdgeInsets.all(30),
                                    child: Column(
                                      mainAxisSize: MainAxisSize.min,
                                      children: [
                                        SizedBox(
                                          height: 20,
                                        ),
                                        Center(
                                            child: Text(
                                          'Weight',
                                          style: TextStyle(
                                              color: kMainColor7,
                                              fontSize: 18,
                                              fontWeight: FontWeight.bold),
                                        )),
                                        SizedBox(
                                          height: 20,
                                        ),
                                        NumberPicker.decimal(
                                          minValue: 40,
                                          maxValue: 250,
                                          initialValue: lastWeight ?? weight,
                                          onChanged: (value) => setState(
                                            () {
                                              weight = value;
                                              lastWeight = value;
                                            },
                                          ),
                                        ),
                                        SizedBox(
                                          height: 20,
                                        ),
                                      ],

Ответы (0 шт):