0
votes

the error is simple i dont know how to solve the problem please help

import 'package:flutter/material.dart';

class CheetahInput extends StatelessWidget {
  final String? labelText;
  final VoidCallback? onSaved;

  CheetahInput({@required this.labelText, @required this.onSaved});

  @override
  Widget build(BuildContext context) {
    return TextFormField(
      decoration: InputDecoration(
        fillColor: Colors.white,
        filled: true,
        labelText: labelText,
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(16),
        ),
        floatingLabelBehavior: FloatingLabelBehavior.never,
      ),
      initialValue: '',
      validator: (String? value) {
        return value!.isEmpty ? '$labelText is required' : null;
      },
      onSaved: onSaved,
    );
  }
}

i tried to specify the type with angular brackets but it didnt work i appreciate your help inadvance.

2
onSaved is not VoidCallback ! You should provide customCallback or function with a parameter of String? - Naveen Avidi
could you please provide the code ? - delaram

2 Answers

2
votes

Replace

final VoidCallback? onSaved;

with

final Function(String)? onSaved;
0
votes

Replace

final VoidCallback? onSaved;

with

final FormFieldSetter<String>? onSaved;