0

I'm trying to debug an ios app that I wrote with flutter. The android version works fine, but the ios version seems to constantly spit up when getting to a specific screen by pushing a button. The error is:

Another exception was thrown: FormatException: Invalid number (at character 1)

My research shows there is a null value somewhere on the page, but I can't see it, and I can't figure out how to debug inside the ios simulator from Android Studio. Can anyone suggest?

Code for the page I am going to is below:

//1) fO2(default to 4.76)
//2) Bar vs PSI?? Probably in V2
//3) Owner Name
import 'package:ccrchecklist/main.dart';
import 'package:flutter/material.dart';
import './myUtils.dart';

class settingsPage extends StatefulWidget {
  @override
  _settingsPage createState() => _settingsPage();

}

class _settingsPage extends State{
  final _name = TextEditingController(text: myUtils.getSharedPref('name'));

  int _radioBarPSIValue = int.parse(myUtils.getSharedPref('bar'));
  int _radioDecimalValue = int.parse(myUtils.getSharedPref('decimal'));


  final _formKey = GlobalKey<FormState>();
  bool _validator1 = false;
  bool _validator2 = false;
  bool _validator3 = false;

  String name = '';


  void _handleBarPSIRadioValueChange(int value) {
    setState(() {
      _radioBarPSIValue = value;
      print("Setting Bar PSI");
      switch (_radioBarPSIValue) {
        case 0:
          myUtils.setSharedPref('bar', '0');  //Set to Bar
          break;
        case 1:
          myUtils.setSharedPref('bar', '1');  //Set to PSI
          break;
      }
    });
  }
  void _handleDecimalRadioValueChange(int value) {
    setState(() {
      _radioDecimalValue = value;
      print("Setting Bar PSI");
      switch (_radioDecimalValue) {
        case 0:
          myUtils.setSharedPref('decimal', '0');  //Set to Bar
          break;
        case 1:
          myUtils.setSharedPref('decimal', '1');  //Set to PSI
          break;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: ListView(
          padding: EdgeInsets.symmetric(horizontal: 24.0),
          children: <Widget>[
            SizedBox(height: 120.0),
            //Name
            Form(
              key: _formKey,
              child: Column(
                children: <Widget>[
                  //Name field
                  new TextFormField(
                    keyboardType: TextInputType.text,
                    controller: _name,
                    autovalidate: _validator1,
                    decoration: const InputDecoration(
                      icon: Icon(Icons.person),
                      hintText: 'Your Name',
                      labelText: 'Name',
                    ),
                    onChanged: (String value) {
                      name = _name.text;
                      setState(() {
                        _validator1 = true;
                      });
                    },
                    validator: (String value) {
                      if(value.isEmpty){
                        return "Field is required";
                      }
                      else {
                        return null;
                      }
                    },
                  ),
                  //Bar or PSI
                  Row(
                    children: <Widget>[
                      Radio(
                        value: 0,
                        groupValue: _radioBarPSIValue,
                        onChanged: _handleBarPSIRadioValueChange,
                      ),
                      Text(
                        'Bar',
                        style: new TextStyle(fontSize: 16.0),
                      ),
                      Radio(
                        value: 1,
                        groupValue: _radioBarPSIValue,
                        onChanged: _handleBarPSIRadioValueChange,
                      ),
                      Text(
                        'PSI',
                        style: new TextStyle(fontSize: 16.0),
                      ),
                    ]
                  ),
                  ButtonBar(
                    children: <Widget>[
                      //Clear Button
                      FlatButton(
                        child: Text('Cancel'),
                        onPressed: () {
                          Navigator.push(
                            context,
                            MaterialPageRoute(builder: (context) => HomeScreen()),);
                        },
                      ),
                      RaisedButton(
                        child: Text('SAVE'),
                        onPressed: () {
                          print(name);
                          _handleBarPSIRadioValueChange(_radioBarPSIValue);
                          if(name != '')
                            myUtils.setSharedPref('name', name);
                          Navigator.push(
                            context,
                            MaterialPageRoute(builder: (context) => HomeScreen()),);
                        }
                      ),
                    ]
            ),
          ],
        ),
      ),])));
  }
}```
llaskin
  • 789
  • 2
  • 9
  • 24
  • Please post the entire error log – imgkl Jan 18 '21 at 08:55
  • Literally the only thing that displays on the ios simulator is Another exception was thrown: FormatException: Invalid number (at character 1). If I had the rest, i'd probably be able to trace it. – llaskin Jan 18 '21 at 17:52

0 Answers0