Rehan6225 / MOVIE_BOX

Final repository for Yellow class Flutter assignment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MovieBox

Collection of Watched Movies

Dart Flutter Sqflite

💻Task

  • Build a simple aesthetic app to add/edit/delete/list movies that a user has watched.
  • Show an infinite scrollable listview containing all the movies that a user has created.
  • Implement a form to add a new movie or edit an existing one. (Fields kept: Name, Director of the movie)
  • Store the data in either hive or sqflite local database.

👀Overview

Watched movies Add movie

🎬Preview

gif

📜Database connection

class DBProvider {
  DBProvider._();
  static final DBProvider dataBase = DBProvider._();
  static Database? _database;

  Future<Database?> get database async {
    if (_database != null) return _database;

    // if _database is null we instantiate it
    _database = await initDataBase();
    return _database;
  }

  Future<Database> initDataBase() async {
    Directory dir = await getApplicationDocumentsDirectory();
    String path = dir.path + 'movie.db';
    final movieDb = await openDatabase(path, version: 1, onCreate: _createDb);
    return movieDb;
  }

  void _createDb(Database db, int version) async {
    await db.execute(
        'CREATE TABLE tasks (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,dname TEXT)');
  }

  addNewTask(Task newTask) async {
    final db = await database;
    db!.insert("tasks", newTask.toMap(),
        conflictAlgorithm: ConflictAlgorithm.replace);
  }

  Future<dynamic> getTask() async {
    final db = await database;
    var res = await db!.query("tasks");
    if (res.length == 0) {
      return null;
    } else {
      var resultMap = res.toList();
      return resultMap.isNotEmpty ? resultMap : Null;
    }
  }
}

How to run

- flutter packages get (Build the app)
- flutter run->
- Run the app (Simulator/ Real Device )

About

Final repository for Yellow class Flutter assignment


Languages

Language:Dart 70.6%Language:HTML 25.5%Language:Swift 2.8%Language:Kotlin 0.9%Language:Objective-C 0.3%