flutter_riverpod: ^2.3.7
go_router: ^10.1.0
flutter 3.13.0
code:
go_router:context.pushNamed("/home",queryParameters: {"arguments": user.name});
ControllerCode:
`
final ControllerProvider =
StateNotifierProvider.autoDispose<Controller, State>((ref) => Controller());
class State {}
class Controller extends StateNotifier<State> {
Controller() : super(State()) {
//How should I obtain it correctly arguments ???
if (arguments != null) {
state.textEditingController.text = Get.arguments;
getData(page: 1, keyword: Get.arguments);
} else {
getData(page: 1);
}
}
}
`
pageCode:
class Page extends ConsumerStatefulWidget {
const Page({super.key});
@override
_State createState() => _State();
}
class _State extends ConsumerState<Page> {
late State state;
late Controller controller;
@override
Widget build(BuildContext context) {
final routeState = GoRouterState.of(context);
if (routeState.uri.queryParameters["arguments"] != null) {
routeState.uri.queryParameters["arguments"]!;
//print username01
}
state = ref.watch(ControllerProvider);
controller = ref.watch(ControllerProvider.notifier);
return Container();
}
}
How should I obtain it correctly arguments to Controller(arguments)
?
ControllerProvider
Can be obtained GoRouterState.of(context)
to Controller?
Controller get GoRouterState.of(context).uri.queryParameters