To save a Boolean variable in SQFLite, you can first convert the Boolean value to an integer (0 or 1) using a ternary operator. For example:
bool myBool = true;
int myInt = myBool ? 1 : 0;
Then, you can use the insert
or update
method from SQFLite to store the integer value in a database column with the appropriate data type, such as INTEGER
or BOOLEAN
. For example:
await db.insert('myTable', {'myBooleanColumn': myInt});
To retrieve the Boolean value from the database, you can read the integer value from the column and convert it back to a Boolean using another ternary operator. For example:
int myIntFromDb = await db.query('myTable', columns: ['myBooleanColumn']);
bool myBoolFromDb = myIntFromDb == 1 ? true : false;
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-08-18 11:00:00 +0000
Seen: 18 times
Last updated: Feb 03 '23
What are the steps for utilizing Swashbuckle to give Model documentation and Example Value?
How can I transfer variables to a pipeline variable?
How can a DateTime Zone be changed to another DateTime Zone?
How can we direct to a randomly selected entry from a list using Nginx?
How can I load a text file in gensim?
How to stop the for-loop when a specific condition is fulfilled?
How can CSS variables in Angular Material 15 be replaced?
How can you obtain several parameters using a single GET request?