-1

I send a boolean variable to SQL database, But when i retrieve it it was a string.

The Entered Data Code Is:

database.execute(
          "CREATE TABLE tasks (id integer PRIMARY KEY ,isFinished BOOLEAN) ");

When i retrieve the data the run time type is String!

the code is:

  Future<bool> checkBoxValue({required int id})async{
    Database? _database = await _createDB();
    List<Map<String, Object?>> isFinished= await _database.rawQuery("SELECT isFinished from tasks where id = '$id'");
   Object? c= isFinished[0]['isFinished'] ;
   print("\n isFinished:${c.runtimeType} \n");
     return true;
  }

1 Answers1

0

you can modify your source code like below code:

 database.execute(
          "CREATE TABLE tasks (id integer PRIMARY KEY ,isFinished BOOLEAN NOT NULL CHECK (isFinished IN (0, 1))) ");

it will be worked. thanks

  • please let me know. thanks – Flutter Box Oct 18 '21 at 10:15
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 18 '21 at 10:51