SQLite中BOOL值的类型是什么?我想在我的表中存储TRUE/FALSE值.
我可以创建一个INTEGER列并在其中存储值0或1,但它不是实现BOOL类型的最佳方法.
有办法吗?
谢谢.
我见过C中的定义
#define TRUE (1==1)
#define FALSE (!TRUE)
Run Code Online (Sandbox Code Playgroud)
这有必要吗?简单地将TRUE定义为1,将FALSE定义为0有什么好处?
使用flutter我有这个模型
class Task {
String color;
String env;
String id;
String name;
String description;
bool isBuyIt;
bool isOnBacklog;
}
Run Code Online (Sandbox Code Playgroud)
我使用SwitchListTile是为了更改isBuyItand的布尔值isOnBacklog
SwitchListTile(
activeColor: HexColor(task.color),
title: Text("Do you have it?"),
value: task.isBuyIt,
onChanged: (bool value) {
setState(() {
task.isBuyIt = value;
});
},
secondary: IconButton(
icon: Icon(Icons.shopping_cart),
onPressed: null,
color: HexColor(task.color),
),
)
Run Code Online (Sandbox Code Playgroud)
我正在使用sqflite: ^1.3.0,正如你所知,它不支持 bool value。我这样制作表格:
Future _onCreate(Database db, int version) async {
await db.execute('''
CREATE TABLE $table (
$columnId …Run Code Online (Sandbox Code Playgroud)