logo
Tags down

shadow

How to solve ˜The getter 'documentID' was called on null.˜?


By : Center 12
Date : September 16 2020, 08:00 PM
I wish this help you Since you have a lot of code here, but haven't noted a specific line where the error occurs, I'll guess it happens here:
code :
Firestore.instance
    .collection("lanchonetes")
    .document(snapshot.documentID)
    .updateData({'likes': FieldValue.increment(_liked ? -1 : 1)});
DocumentSnapshot snapshot;


Share : facebook icon twitter icon

The getter 'storeNumber' was called on null (Receiver: null)


By : Judi Kittelty
Date : March 29 2020, 07:55 AM
I hope this helps . You can use the following approach.
Remove the following lines from your code:
code :
//get our entity class
StoreData storeDate;
String storeNumber;
String repName;
String repCell;
DateTime transactionDate;
    import 'package:flutter/material.dart';

import 'FeedBack.dart';
import 'StoreData.dart';

void main() {
  runApp(MaterialApp(
    title: 'Navigation Basics',
    home: FirstScreen(),
  ));
}


// get variables from entity class
String storeNumber;
String repName;
String repCell;
DateTime transactionDate = DateTime.now();

class FirstScreen extends StatefulWidget {
  @override
  _FirstScreenState createState() => _FirstScreenState();
}

class _FirstScreenState extends State<FirstScreen> {
  GlobalKey<FormState> _key = GlobalKey();
  bool _validate = false;

  _sendData() {

    _key.currentState.save();

    Navigator.push(
      context,
      MaterialPageRoute(
          builder: (context) => FeedBack(
              storeData: StoreData(
                  storeNumber, repName, repCell, transactionDate))),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Test App'),
        ),
        body: new SingleChildScrollView(
          child: new Container(
            margin: new EdgeInsets.all(15.0),
            child: new Form(
              key: _key,
              autovalidate: _validate,
              child: formUI(),
            ),
          ),
        ),
      ),
    );
  }

  Widget formUI() {
    return new Column(
      children: <Widget>[
        new TextFormField(
            decoration: new InputDecoration(hintText: 'Store Number'),
            keyboardType: TextInputType.number,
            validator: validateRepCell,
            onSaved: (String val) {
              storeNumber = val;
            }),
        new TextFormField(
            decoration: new InputDecoration(hintText: 'Rep Full Name'),
            validator: validateRepName,
            onSaved: (String val) {
              repName = val;
            }),
        new TextFormField(
            decoration: new InputDecoration(hintText: 'Rep Phone Number'),
            keyboardType: TextInputType.number,
            validator: validateRepCell,
            onSaved: (String val) {
              repCell = val;
            }),
        new SizedBox(height: 15.0),
        new RaisedButton(
          onPressed: _sendData,
          child: new Text('Proceed'),
        )
      ],
    );
  }

// Validate Fields

  String validateRepCell(String value) {
    // String patttern = r'(^[a-zA-Z ]*$)';
    RegExp regExp = new RegExp(r'^[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)$');
    if (value.length == 0) {
      return "Store Number  is Required";
    } else if (!regExp.hasMatch(value)) {
      return "Store Number must be only have numbers";
    }
    return null;
  }

  String validateRepName(String value) {
    String patttern = r'(^[a-zA-Z ]*$)';
    RegExp regExp = new RegExp(patttern);
    if (value.length == 0) {
      return "Rep Name is Required";
    } else if (!regExp.hasMatch(value)) {
      return "Name must be a-z and A-Z";
    }
    return null;
  }


}

How to solve this "The getter 'length' was called on null"


By : user2905055
Date : March 29 2020, 07:55 AM
this one helps. I've looked at your link and tried running the code and I think the issue is in the data returned from your link.
code :
[{"name":"م.م علي ستار باراني","msg":"امتحان مادة قواعد البيانات اول جابترين ","day":"السبت","date":"2019-06-20"}][{"name":"م. امجد عباس التميمي","msg":"امتحان مادة هندسة البرامجيات اول فصلين","day":"الاحد","date":"2019-06-21"},{"name":"م.م علي ستار باراني","msg":"امتحان مادة قواعد البيانات اول جابترين ","day":"السبت","date":"2019-06-20"}]
FormatException (FormatException: Unexpected character (at character 115)
...,"day":"السبت","date":"2019-06-20"}][{"name":"م. امجد عباس التميمي","msg...
                                       ^
)
[{"name":"م.م علي ستار باراني","msg":"امتحان مادة قواعد البيانات اول جابترين ","day":"السبت","date":"2019-06-20"},{"name":"م. امجد عباس التميمي","msg":"امتحان مادة هندسة البرامجيات اول فصلين","day":"الاحد","date":"2019-06-21"},{"name":"م.م علي ستار باراني","msg":"امتحان مادة قواعد البيانات اول جابترين ","day":"السبت","date":"2019-06-20"}]

getter 'classification' was called on null


By : Piotr Walaszek
Date : March 29 2020, 07:55 AM
it should still fix some issue your CLASSIFICATION might not correctly initialized.
please check example below
code :
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

List<Map> _jsonApi1 = [
  {"id": 0, "name": "default 1"}
];
List<Map> _jsonApi2 = [
  {"id": 1, "name": "second 2"},
  {"id": 2, "name": "third 3"}
];
List<Map> _myJson = new List.from(_jsonApi1)..addAll(_jsonApi2);

class _MyHomePageState extends State<MyHomePage> {
  String _mySelection;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: SafeArea(
        child: Column(
          children: <Widget>[
            Container(
              height: 500.0,
              child: new Center(
                child: new DropdownButton<String>(
                  isDense: true,
                  hint: new Text("${_jsonApi1[0]["name"]}"),
                  value: _mySelection,
                  onChanged: (String newValue) {
                    setState(() {
                      _mySelection = newValue;
                    });

                    print(_mySelection);
                  },
                  items: _myJson.map((Map map) {
                    return new DropdownMenuItem<String>(
                      value: map["id"].toString(),
                        child: new Text(
                          map["name"],
                        ),
                    );
                  }).toList(),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

The getter 'text' was called on null


By : user3405586
Date : March 29 2020, 07:55 AM
will help you Since you are only creating the variable, it will always be null. Try this instead:
TextEditingController passController = new TextEditingController();

The getter 'length' was called on null


By : Phalchion
Date : March 29 2020, 07:55 AM
I wish this help you I trying to retrieve my data from API server and present it in my mobile application using flutter .. but i got error , You need to guard against the case when data == null
code :
  body: new Center(
    child: data == null ? Container() : new ListView.builder(
        itemCount: data.length,
        itemBuilder: (BuildContext context, int position) {
          return new ListTile(
            title: new Text('${data[position]['name']}'),
          );
        }),
  ),
shadow
Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk