下面的代码是关于一个带有 Scaffold 的有状态类,它的主体中包含 Listview,它的一个子类是关于一个本身有一些子类的堆栈,我想使用 ListView 作为卡片小部件的子类,以便滚动数据表在卡片里面,但是当我在卡片视图中使用列表视图时,Scaffold 中的所有东西都消失了,但是当没有列表视图时,一切又回来了,
class DevicePageState extends State<DevicePage>{
Widget bodyData()=>DataTable(
columns:<DataColumn>[
DataColumn(
label: Text('?????',style: TextStyle(color: Colors.deepPurple,fontWeight: FontWeight.bold,fontSize: 14.0),),
numeric: false,
onSort: (i,b){},
tooltip: "to display first name of th e name"
),
DataColumn(
label: Text('??????',style: TextStyle(color: Colors.deepPurple,fontWeight: FontWeight.bold,fontSize: 14.0),),
numeric: false,
onSort: (i,b){},
tooltip: "to display Last name of th e name"
),
],
rows: names.map((name)=>DataRow(
cells: [
DataCell(
new Text(name.firstName, style: TextStyle(color: Colors.blueAccent,fontWeight: FontWeight.bold,fontSize: 12.0 ),
),
showEditIcon: false,
placeholder: false,
),
DataCell(
new Text(name.lastName,style: TextStyle(color: …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 json 对象插入数据,以下代码是关于我使用的表
我这样定义数据库帮助器类:
class DatabaseHelper {
static DatabaseHelper _databaseHelper; // Singleton DatabaseHelper
static Database _database; // Singleton Database
String category_Table = 'category_Table';
String category_id = 'category_id';
String device_type_id = 'device_type_id';
String room_id = 'room_id ';
...
Run Code Online (Sandbox Code Playgroud)
await db.execute(
'CREATE TABLE $category_Table($category_id INTEGER PRIMARY KEY UNIQUE , $device_type_id INTEGER, '
'$room_id INTEGER)');
print('category created!');
Run Code Online (Sandbox Code Playgroud)
这是插入函数
Database db = await this.database;
var result = await db.insert(category_Table, category.toMap());
print('category inserted');
return result;
}
Run Code Online (Sandbox Code Playgroud)
这是错误
Exception has occurred.
SqfliteDatabaseException (DatabaseException(table category_Table has no …Run Code Online (Sandbox Code Playgroud) 我将在我的应用程序中使用数据表。
在我的页面中,我有一个背景,这个数据表应该在一个特定的位置(可能是中心),但我不知道如何为那个(数据表)设置对齐方式。
谁能告诉我如何解决这个问题?
我正在尝试将一些数据插入到 sqflite 表中,但在执行插入查询时出错
await db.execute(
'CREATE TABLE $catrgoryTable($category_id INTEGER PRIMARY KEY UNIQUE , $colDeviceTypeId INTEGER, '
'$room_id INTEGER)');
print('category created!');
Run Code Online (Sandbox Code Playgroud)
这是错误
SqfliteDatabaseException (DatabaseException(UNIQUE constraint failed: category_Table.category_id (code 1555)) sql 'INSERT INTO category_Table (category_id, device_type_id, room_id) VALUES (?, ?, ?)' args [1, 1, 1]})
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助:)