#android #firebase #flutter #dart #google-cloud-firestore
#Android #firebase #трепетание #dart #google-облако-firestore
Вопрос:
После обновления firebase я вижу, что firebase-core является обязательным, поэтому я соответствующим образом изменил свой код, но не имею представления о функции initializeApp, поэтому я искал в Интернете по этому поводу и добавил эту строку await Firebase.initializeApp();
, но теперь я получаю эту ошибку
W/DynamiteModule(20840): Local module descriptor class for providerinstaller not found.
I/DynamiteModule(20840): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller(20840): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
W/ConnectivityManager.CallbackHandler(20840): callback not found for CALLBACK_AVAILABLE message
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following StackOverflowError was thrown building _BodyBuilder:
Stack Overflow
The relevant error-causing widget was:
Scaffold file:///Users/masummolla/FlutterProjects/admin/lib/screens/active_user.dart:32:12
When the exception was thrown, this was the stack:
#0 _StringBase.== (dart:core-patch/string_patch.dart:280:7)
#1 _LinkedHashMapMixin._getValueOrData (dart:collection-patch/compact_hash.dart:670:10695)
#2 new FirestoreService (package:admin/services/firestore_service.dart:129:7844)
#3 new FirestoreService (package:admin/services/firestore_service.dart:8:27)
#4 new FirestoreService (package:admin/services/firestore_service.dart:8:27)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following StackOverflowError was thrown building _BodyBuilder:
Stack Overflow
The relevant error-causing widget was:
Scaffold file:///Users/masummolla/FlutterProjects/admin/lib/screens/active_user.dart:32:12
When the exception was thrown, this was the stack:
#0 _StringBase.== (dart:core-patch/string_patch.dart:280:7)
#1 _LinkedHashMapMixin._getValueOrData (dart:collection-patch/compact_hash.dart:670:10695)
#2 new FirestoreService (package:admin/services/firestore_service.dart:129:7844)
#3 new FirestoreService (package:admin/services/firestore_service.dart:8:27)
#4 new FirestoreService (package:admin/services/firestore_service.dart:8:27)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
Я не знаю точной причины
вот мои коды в файле main.dart
import 'package:admin/models/route_generator.dart';
import 'package:admin/user_preferences.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await UserPreferences().init();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
// This widget is the root of your application.
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.amber,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
// ignore: unrelated_type_equality_checks
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: '/',
);
}
}
и вот код для active_user.файл dart
import 'package:admin/screens/class_videos.dart';
import 'package:admin/screens/important_videos.dart';
import 'package:admin/screens/live_class.dart';
import 'package:admin/screens/user_details.dart';
import 'package:admin/screens/weekly_updates.dart';
import 'package:admin/user_preferences.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ActiveUser extends StatefulWidget {
@override
_ActiveUserState createState() => _ActiveUserState();
}
class _ActiveUserState extends State<ActiveUser> {
int landing = 2;
int _page = 2;
@override
void initState(){
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown,DeviceOrientation.portraitUp]);
super.initState();
landing = UserPreferences().landing;
_page=landing;
}
final pageScreen = [ImportantVideos(),WeeklyUpdates(),ClassVideos(),LiveClass(),UserDetails()];
GlobalKey _bottomNavigationKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Badshai Trading Videos'),
actions: [
IconButton(
icon: _page==landing ? Icon(Icons.touch_app,color: Colors.white,) :Icon(Icons.pan_tool,color: Colors.white,),
onPressed: () {
if (_page!=landing){
UserPreferences().landing=_page;
setState(() {
landing=_page;
});
}else if(_page==landing amp;amp; _page!=2){
setState(() {
landing = 2;
UserPreferences().landing=landing;
});
}
},
),
],
),
body: pageScreen[_page],
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: _page,
height: 50.0,
items: <Widget>[
Icon(Icons.important_devices, size: 20,color: _page==0 ?Colors.amber:Colors.black,),
Icon(Icons.multiline_chart, size: 20,color: _page==1 ?Colors.amber:Colors.black,),
Icon(Icons.live_tv, size: 20,color: _page==2 ?Colors.amber:Colors.black,),
Icon(Icons.card_membership, size: 20,color: _page==3 ?Colors.amber:Colors.black,),
Icon(Icons.more, size: 20,color: _page==4 ?Colors.amber:Colors.black,),
],
color: Colors.white,
buttonBackgroundColor: Colors.white,
backgroundColor: Colors.amberAccent,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 400),
onTap: (index) {
setState(() {
_page = index;
});
},
),
);
}
}
Если кто-нибудь может помочь мне выбраться из этого стека, я буду им благодарен
Ответ №1:
Извините, я обнаружил ошибки, использовавшие FirestoreService _ndb = FirestoreService();
эту строку в моем классе FirestoreService, просто прокомментировал ее