JinsarAhmed /
Android-App-Development-CODE
This repository contains all the dart/flutter files of My Flutter Learning Journey
Loading repository data…
rhedgpeth / repository
This repository contains a simple Flutter application that manages contact information using SQLite (via SQFLite).
This repository contains a simple Flutter application that manages contact information using SQLite (via SQFLite).
To run this application be sure to check out the Flutter documentation for getting started.
To use SQLite within a Flutter application you're going to need to add a couple dependencies to the pubspec.yaml file.
Note: The Dart ecosystem uses packages to manage shared software such as libraries and tools. To get Dart packages, you use the pub package manager. Find more information on Dart package management here.
More specifically, the sqflite and path_provider packages are required.
dependencies:
flutter:
sdk: flutter
sqflite: any
path_provider: any
From there a SQLite database (and tables) can be created and used within the application.
For this applicaiton I have put all of the SQFLite usages within database_helper.dart.
import 'dart:async';
import 'dart:io' as io;
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:rolodex/models/base_model.dart';
import 'package:sqflite/sqflite.dart';
class DatabaseHelper {
static final DatabaseHelper _instance = DatabaseHelper.internal();
factory DatabaseHelper() => _instance;
static Database? _db;
Future<Database> get db async {
_db ??= await init();
return _db!;
}
DatabaseHelper.internal();
Future<Database> init() async {
io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join(documentsDirectory.path, "main.db");
return openDatabase(path, version: 1, onCreate: onCreate);
}
void onCreate(Database db, int version) async =>
await db.execute('CREATE TABLE contacts (id INTEGER PRIMARY KEY NOT NULL, firstName STRING, lastName STRING, phone STRING, email STRING)');
Future<List<Map<String, dynamic>>> query(String table) async => (await db).query(table);
Future<int> insert(String table, BaseModel model) async => (await db).insert(table, model.toMap());
Future<int> update(String table, BaseModel model) async => (await db).update(table, model.toMap(), where: 'id = ?', whereArgs: [model.id]);
Future<int> delete(String table, BaseModel model) async => (await db).delete(table, where: 'id = ?', whereArgs: [model.id]);
}
If you have any questions or feedback for this sample please feel free to submit an issue here or email me at rob.hedgpeth@gmail.com.
Happy coding!
Selected from shared topics, language and repository description—not editorial ratings.
JinsarAhmed /
This repository contains all the dart/flutter files of My Flutter Learning Journey
Abhijit2505 /
Flutter is an open-source UI software development kit created by Google. It is used to develop applications for Android, iOS, Windows, Mac, Linux, Google Fuchsia and the web from a single codebase. This repository contains all my flutter practise codes.
davocarli /
Repository containing my learning/practice of flutter following this course: https://www.udemy.com/course/learn-flutter-dart-to-build-ios-android-apps/