dart
1import 'package:firebase_core/firebase_core.dart'; 2import 'package:flutter/material.dart'; 3import 'package:provider/provider.dart'; 4import 'package:todoapp/main_model.dart'; 5 6void main() async{ 7 WidgetsFlutterBinding.ensureInitialized(); 8 await Firebase.initializeApp(); 9 runApp(MyApp()); 10} 11 12class MyApp extends StatelessWidget { 13 14 Widget build(BuildContext context) { 15 return MaterialApp( 16 title: 'Flutter todo', 17 home: ChangeNotifierProvider<MainModel>( 18 create: (_) => MainModel()..getTodoList(), 19 child: Scaffold( 20 appBar: AppBar( 21 title: Text('flutter todo'), 22 ), 23 body: Consumer<MainModel>(builder: (context, model, child) { 24 final todoList = model.todoList; 25 return ListView( 26 children: todoList 27 .map( 28 (todo) => ListTile( 29 title: Text(todo.title), 30 ), 31 ).toList(), 32 ); 33 } 34 ), 35 floatingActionButton: FloatingActionButton( 36 onPressed: (){ 37 38 }, 39 tooltip: 'Increment', 40 child: Icon(Icons.add), 41 ), 42 ) 43 ), 44 ); 45 } 46}
dart
1import 'package:cloud_firestore/cloud_firestore.dart'; 2 3class Todo{ 4 Todo(DocumentSnapshot doc){ 5 6 this.title = doc.data()['title']; 7 8 final Timestamp timestamp = doc.data()['createdAt']; 9 this.createdAt = timestamp.toDate(); 10 } 11 12 String title; 13 DateTime createdAt; 14}
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:todoapp/todo.dart'; class MainModel extends ChangeNotifier{ List<Todo> todoList = []; Future getTodoList() async { final snapshot = await FirebaseFirestore.instance.collection('todoList').get(); final docs = snapshot.docs; final todoList = docs.map((doc) => Todo(doc)).toList(); this.todoList = todoList; notifyListeners(); } }
###エラー文
W/example.apptod(11143): Accessing hidden method Ldalvik/system/CloseGuard;->close()V (greylist,core-platform-api, linking, allowed)
W/DynamiteModule(11143): Local module descriptor class for providerinstaller not found.
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
I/DynamiteModule(11143): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(11143): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/example.apptod(11143): Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
D/skia (11143): Shader compilation error
D/skia (11143): ------------------------
D/skia (11143): Errors:
D/skia (11143):
一度動作したのですが、ビルドし直すとこのエラーが表示されました。
ググってみたのですがわかりませんでした
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー