0

I'm new to flutter and am trying to implement a form app with local database for persistence. I cannot figure out how to save a user picked image to the database. I referred to this answer but in it the picture does not have the type of Image. This is my model class:

import 'package:flutter/material.dart';

class Student {
  Student({
    required this.id,
    required this.profileImage,
    required this.rollNo,
    required this.fullName,
    required this.standard,
    required this.description,
    required this.entryDate,
  });

  final String id;
  final Image profileImage;
  final int rollNo;
  final String fullName;
  final int standard;
  final String? description;
  final String entryDate;
}

The table:

await database.execute(''' 
CREATE TABLE $_tableName (
  id            TEXT      PRIMARY KEY   NOT NULL, 
  profile_image BLOB,
  roll_no       INTEGER   NOT NULL, 
  full_name     TEXT      NOT NULL, 
  standard      INTEGER   NOT NULL, 
  description   TEXT, 
  entry_date    TIMESTAMP NOT NULL
)
''');

How can I achieve this?

Or is there any way to convert user picked image to Uint8List?

Are there any packages that can achieve this?

0 Answers0