Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
dispatcher_test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gavin An
dispatcher_test
Commits
18214a76
Commit
18214a76
authored
Nov 07, 2024
by
Gavin An
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
파이어스토어 테스트
parent
3ffbc5c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
33 deletions
+56
-33
lib/fire_store_test_page.dart
lib/fire_store_test_page.dart
+17
-7
lib/main.dart
lib/main.dart
+39
-26
No files found.
lib/fire_store_test_page.dart
View file @
18214a76
...
...
@@ -11,14 +11,25 @@ class FireStoreTestPage extends StatefulWidget {
class
_FireStoreTestPageState
extends
State
<
FireStoreTestPage
>
{
final
FirebaseFirestore
store
=
FirebaseFirestore
.
instance
;
late
Stream
<
QuerySnapshot
<
Map
<
String
,
dynamic
>>>
querySnapShot
;
late
ScrollController
sc
;
List
<
QueryDocumentSnapshot
<
Map
<
String
,
dynamic
>>>
documents
=
[];
@override
void
initState
()
{
super
.
initState
();
querySnapShot
=
store
.
collection
(
'baecha'
)
// .where('baljuGroupId', whereIn: ['baecha_group_001', 'baecha_group_002'])
.
snapshots
();
sc
=
ScrollController
();
querySnapShot
=
store
.
collection
(
'baecha'
)
// .where('baljuGroupId', whereIn: ['baecha_group_001', 'baecha_group_002'])
.
orderBy
(
'createDate'
,
descending:
true
)
.
snapshots
();
querySnapShot
.
listen
(
(
event
)
{
if
(
documents
.
isNotEmpty
)
{
sc
.
animateTo
(
0
,
duration:
const
Duration
(
milliseconds:
300
),
curve:
Curves
.
ease
);
}
},
);
}
@override
...
...
@@ -29,11 +40,10 @@ class _FireStoreTestPageState extends State<FireStoreTestPage> {
if
(!
snapshot
.
hasData
)
{
return
const
CircularProgressIndicator
();
}
List
<
QueryDocumentSnapshot
<
Map
<
String
,
dynamic
>>>
documents
=
snapshot
.
data
!.
docs
;
documents
=
snapshot
.
data
!.
docs
;
return
Expanded
(
child:
ListView
.
builder
(
shrinkWrap:
true
,
reverse:
true
,
controller:
sc
,
itemCount:
documents
.
length
,
itemBuilder:
(
context
,
index
)
{
final
item
=
documents
[
index
];
...
...
lib/main.dart
View file @
18214a76
...
...
@@ -4,17 +4,12 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import
'package:dispatcher_test/fire_store_test_page.dart'
;
import
'package:dispatcher_test/firebase_options.dart'
;
import
'package:dispatcher_test/module/dependency_inject.dart'
;
import
'package:dispatcher_test/notification_page.dart'
;
import
'package:dispatcher_test/speech_to_text_page.dart'
;
import
'package:dispatcher_test/text_to_speech_page.dart'
;
import
'package:dispatcher_test/text_to_speech_util.dart'
;
import
'package:firebase_core/firebase_core.dart'
;
import
'package:firebase_messaging/firebase_messaging.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_local_notifications/flutter_local_notifications.dart'
;
import
'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
import
'package:uuid/uuid.dart'
;
...
...
@@ -109,7 +104,7 @@ void main() async {
await
Firebase
.
initializeApp
(
options:
DefaultFirebaseOptions
.
currentPlatform
);
FirebaseMessaging
.
onBackgroundMessage
(
_firebaseMessagingBackgroundHandler
);
FirebaseFirestore
.
instance
.
settings
=
const
Settings
(
persistenceEnabled:
tru
e
,
persistenceEnabled:
fals
e
,
);
// TODO 카카오 Login init
...
...
@@ -271,9 +266,44 @@ class _MyHomePageState extends State<MyHomePage> {
crossAxisAlignment:
CrossAxisAlignment
.
end
,
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
// IconButton(onPressed: () {}, icon: Icon(Icons.add)),
// IconButton(onPressed: () {}, icon: Icon(Icons.mic)),
FloatingActionButton
(
mini:
true
,
tooltip:
'Delete'
,
child:
const
Icon
(
Icons
.
delete
),
onPressed:
()
async
{
QuerySnapshot
colRef
=
await
store
.
collection
(
'baecha'
).
get
();
for
(
var
element
in
colRef
.
docs
)
{
DocumentReference
<
Map
<
String
,
dynamic
>>
ref
=
store
.
collection
(
'baecha'
).
doc
(
element
.
id
);
await
ref
.
delete
();
}
},
),
const
SizedBox
(
width:
30
,
),
FloatingActionButton
(
mini:
true
,
tooltip:
'Modify'
,
child:
const
Icon
(
Icons
.
published_with_changes
),
onPressed:
()
async
{
// store.collection('baecha').doc().
Random
rd
=
Random
();
int
rdNum
=
rd
.
nextInt
(
20
);
int
rdNum2
=
rd
.
nextInt
(
30
);
// String rdStr = sample[rdNum];
QuerySnapshot
<
Map
<
String
,
dynamic
>>
firstDoc
=
await
store
.
collection
(
'baecha'
)
.
orderBy
(
'createDate'
,
descending:
true
)
.
get
();
String
firstId
=
firstDoc
.
docs
[
0
].
id
??
''
;
store
.
collection
(
'baecha'
).
doc
(
firstId
).
update
({
'callCnt'
:
rdNum
,
'passCnt'
:
rdNum2
});
},
),
const
SizedBox
(
width:
30
,
),
FloatingActionButton
(
mini:
true
,
tooltip:
'Increment'
,
child:
const
Icon
(
Icons
.
add
),
onPressed:
()
{
...
...
@@ -282,7 +312,7 @@ class _MyHomePageState extends State<MyHomePage> {
int
callNum
=
rd
.
nextInt
(
20
);
int
passNum
=
rd
.
nextInt
(
15
);
int
minRan
=
rd
.
nextInt
(
30
);
DateTime
dt
=
DateTime
.
now
()
.
add
(
Duration
(
minutes:
minRan
))
;
DateTime
dt
=
DateTime
.
now
();
// String rdStr = sample[rdNum];
var
uuid
=
const
Uuid
();
String
baljuGroupId
=
'baecha_group_00
$rdNum
'
;
...
...
@@ -294,23 +324,6 @@ class _MyHomePageState extends State<MyHomePage> {
});
},
),
const
SizedBox
(
width:
30
,
),
FloatingActionButton
(
tooltip:
'Modify'
,
child:
const
Icon
(
Icons
.
published_with_changes
),
onPressed:
()
async
{
// store.collection('baecha').doc().
Random
rd
=
Random
();
int
rdNum
=
rd
.
nextInt
(
20
);
int
rdNum2
=
rd
.
nextInt
(
30
);
// String rdStr = sample[rdNum];
QuerySnapshot
<
Map
<
String
,
dynamic
>>
firstDoc
=
await
store
.
collection
(
'baecha'
).
get
();
String
firstId
=
firstDoc
.
docs
[
firstDoc
.
docs
.
length
-
1
].
id
??
''
;
store
.
collection
(
'baecha'
).
doc
(
firstId
).
update
({
'callCnt'
:
rdNum
,
'passCnt'
:
rdNum2
});
},
),
],
),
// This trailing comma makes auto-formatting nicer for build methods.
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment