[Improvement] set or use url strategy
Closed this issue · 1 comments
Pr47h4m commented
I've similar issue [issue]
in my case I'm using firebase as backend
my main.dart
file looks like:
import 'firebase_options.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:firebase_core/firebase_core.dart';
import 'exports/e_main.dart'; // all other imports are exported here
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(Travel());
}
class Travel extends StatelessWidget {
Travel({Key? key}) : super(key: key);
final Future<FirebaseApp> _initialization = Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _initialization,
builder: (context, snapshot) {
if (snapshot.hasError) {
// return error page
return const SomethingWentWrong();
}
if (snapshot.connectionState == ConnectionState.done) {
// return app
return ChangeNotifierProvider(
create: (context) => PAuth(),
child: const App(),
);
}
// return loading
return const Loading();
},
);
}
}
So here, first MaterialApp
will be from Loading
Widget
But its not possible for MyApplication to add GoRouter
in Loading Widget
I tried setting url strategy explicitly but then go router don't understand paths correctly
I have a suggestion
There should be following 2 properties in GoRouter
1) setUrlStrategy
2) useUrlStrategy
If setUrlStrategy
is not null
then set and use specified url strategy
else useUrlStrategy
will only be used to resolve path