Flutter DatabaseException(UNIQUE constraint failed)
Solution 1:
The table category_Table
has a unique constraint field on it, the error shows that you tried to enter a value for category_id
that it already exists, which violates primary key's uniqueness constraint for this field. Only one row can exist with a given ID value. So If you're trying to insert a row, be sure that your category_id
have a unique value, or if you don't care about generating ids by yourself, you can add AUTOINCREMENT
setting to your category_id
column definition. This way it will be filled automatically and each row will have its own unique value.