**
eror is here -> Program is saying ->The argument type 'String Function(String)' can't be assigned to the parameter type 'String? Function(String?)?'. İn the validator are and under line , I Wrote eror . Can you help me . I am new at this technolgy . Thank you for your time
**
import 'package:asdasd/Validation/Student_Validator.dart';
import 'package:asdasd/models/Student.dart';
import 'package:flutter/material.dart';
class StudentAdd extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _StudentAddState();
}
}
class _StudentAddState extends State with StudentValidationMixin {
var student = Student.withoutinfo();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Yeni öğrenci ekleme "),
),
body: Container(
margin: EdgeInsets.all(20.0),
child: Form(
child: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: "Öğrencinin Adı", hintText: "Musa Develi"),
validator: validateFirstName,//eror
onSaved: (String value){//eror
student.firstName=value;//eror
},
),
],
),
),
),
);
}
}
class StudentValidation {
}
CodePudding user response:
i'm guessing validateFirstName
is a function, right? You have to make your validator function the same as the validator,
String? Function(String?)
String
is not the same as String?
, the first means the value cannot be null, the second means it can be null.
this happened because null-safety is enabled