-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
41 lines (37 loc) · 1016 Bytes
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import 'package:flutter/material.dart';
import 'package:flutter_floor_sample/mydb_model.dart';
import 'package:flutter_floor_sample/scoped_model.dart';
import 'package:flutter_floor_sample/user.dart';
main() {
runApp(MaterialApp(
title: 'floor sample',
home: App(),
));
}
class App extends StatefulWidget {
App({Key key}) : super(key: key);
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ScopedModel(
model: MydbModel(),
child: ScopedModelDescendant<MydbModel>(
builder: (context, _, model) => StreamBuilder<User>(
stream: model.myDatabase.userDao.getUserInfo(),
builder: (_, snapshot) {
if (!snapshot.hasData) {
return Text('user not found');
} else {
return Text('user found');
}
},
),
),
),
);
}
}