Skip to content

Commit 60ce294

Browse files
committed
Adds new tutorial
1 parent 3c33df0 commit 60ce294

File tree

20 files changed

+1465
-0
lines changed

20 files changed

+1465
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: d408d302e22179d598f467e11da5dd968dbdc9ec
8+
channel: stable
9+
10+
project_type: app
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# sqflite_migration_example
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE todos(
2+
id INTEGER PRIMARY KEY,
3+
title TEXT,
4+
complete INT
5+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE todos ADD description TEXT;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:get_it/get_it.dart';
2+
import 'package:sqflite_migration_example/services/database_service.dart';
3+
import 'package:sqflite_migration_service/sqflite_migration_service.dart';
4+
import 'package:stacked_services/stacked_services.dart';
5+
6+
final locator = GetIt.instance;
7+
8+
void setupLocator() {
9+
locator.registerLazySingleton(() => NavigationService());
10+
locator.registerLazySingleton(() => DatabaseService());
11+
locator.registerLazySingleton(() => DatabaseMigrationService());
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/scheduler.dart';
3+
import 'package:sqflite_migration_example/app/locator.dart';
4+
import 'package:sqflite_migration_example/ui/router.dart' as router;
5+
import 'package:sqflite_migration_example/ui/startup/startup_view.dart';
6+
import 'package:stacked_services/stacked_services.dart';
7+
8+
void main() {
9+
setupLocator();
10+
runApp(MyApp());
11+
}
12+
13+
class MyApp extends StatelessWidget {
14+
// This widget is the root of your application.
15+
@override
16+
Widget build(BuildContext context) {
17+
18+
19+
return MaterialApp(
20+
title: 'Flutter Demo',
21+
navigatorKey: locator<NavigationService>().navigatorKey,
22+
home: StartupView(),
23+
onGenerateRoute: router.Router.onGenerateRoute,
24+
);
25+
}
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import 'package:freezed_annotation/freezed_annotation.dart';
2+
3+
part 'todo.freezed.dart';
4+
part 'todo.g.dart';
5+
6+
@freezed
7+
abstract class Todo with _$Todo {
8+
Todo._();
9+
10+
factory Todo({
11+
int id,
12+
@required String title,
13+
String description,
14+
@Default(0) int complete,
15+
}) = _Todo;
16+
17+
factory Todo.fromJson(Map<String, dynamic> json) => _$TodoFromJson(json);
18+
19+
bool get isComplete => complete == 1 ? true : false;
20+
}

057-sqlite-and-migrations/lib/models/todo.freezed.dart

Lines changed: 198 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

057-sqlite-and-migrations/lib/models/todo.g.dart

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)