riverpod within a flutter package #1613
Replies: 9 comments 5 replies
-
You probably want to offer a widget that users should put above their app |
Beta Was this translation helpful? Give feedback.
-
I want a flutter package that can go inside an Android iOS flutter or web
app.
It just happens to be going in a flutter app so far
....sent from my phone
…On Sat, Sep 10, 2022, 1:45 AM Remi Rousselet ***@***.***> wrote:
You probably want to offer a widget that users should put above their app
—
Reply to this email directly, view it on GitHub
<#1613 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXBGYOO6QR5Z44KLLSSCR3V5QU7XANCNFSM6AAAAAAQI4W5G4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
@neiljaywarner did you get a solution? |
Beta Was this translation helpful? Give feedback.
-
I don't recall but try remis idea :) |
Beta Was this translation helpful? Give feedback.
-
What's the purpose of your package and how does the user interact with it?
If they trigger it with a button then either the screen that launches or
the button could be the widget for example
....sent from my phone
…On Wed, Sep 20, 2023, 11:33 AM akshaydoshi2 ***@***.***> wrote:
Ah Thanks!
But I'm unable understand what exactly to do to offer a widget that users
should put above their app.
—
Reply to this email directly, view it on GitHub
<#1613 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXBGYJBYQD3XTHMTYH2IYTX3MLHPANCNFSM6AAAAAAQI4W5G4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
So wrap the screen you navigate to in providerscope?
....sent from my phone
…On Wed, Sep 20, 2023, 12:28 PM akshaydoshi2 ***@***.***> wrote:
My package has 3 widgets (3 screens to be precise). The user can interact
with the widget on a button press and can simply navigator.push to the
package.
The user can pop these screens and come back to the parent app.
Right now I have to wrap the main() in the parent app with a
ProviderScope for everything to function.
What I want to do is make the package independent so that the user does
not have to import riverpod and wrap it with ProviderScope in the parent
app.
—
Reply to this email directly, view it on GitHub
<#1613 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXBGYMU7DVDYDSJ6YRIYZLX3MRUBANCNFSM6AAAAAAQI4W5G4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Maybe put both buttons in a container or stack? :)
....sent from my phone
…On Thu, Sep 21, 2023, 9:48 AM akshaydoshi2 ***@***.***> wrote:
@neiljaywarner <https://github.com/neiljaywarner> I did try your
suggestion. But it doesn’t seem to work. It creates separate instances of
ProviderScope and so separate instances of the providers are also created.
—
Reply to this email directly, view it on GitHub
<#1613 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXBGYI4V7QAO6JHZOFE2RDX3RHU3ANCNFSM6AAAAAAQI4W5G4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Probably too late but the solution is to encapsulate your "pages" inside your own navigator final _navigatorKey = GlobalKey<NavigatorState>();
@override
Widget build(BuildContext context) {
return ProviderScope(
child: Navigator(
key: _navigatorKey,
initialRoute: 'exampleRouteName',
onGenerateRoute: _onGenerateRoute,
),
);
} then use |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm trying to use riverpod for a completely self-contained package.
is this a dumb idea? It seemed to be going fairly well or even really well until we navigated to another page. Then as you can imagine I lost the providerscope since the provider scope was in the "inner shell" module.
eg
Outer Dummy App1
runApp(DriverWidgetThatHasAppBarAndScaffoldAndHardcodedParametersAndWrapsActualPackageWrapperWidget())
Real OuterApp: tap some things, get some info from db/network/whatever, pass it to ActualPackageWrapperWidget(param1,param2)
package widget is in directory project root/pakcage/actual_package and has its own pubspec.yaml obviously etc
ActualPackageWrapperWidget is like this
`
class ActualPackageWrapperWidget extends StatelessWidget {
const ActualPackageWrapperWidget({Key? key, required this.param1, required this.param2}) : super(key: key);
final String param1, param2;
@OverRide
Widget build(BuildContext context) => ProviderScope(child: ActualPackageWidget(param1,param2));
}
`
so as you can imagine since MaterialApp is in the "host" package then pushing a new navigator route loses my ProviderScope.
Of course, the biggest thing this causes problems for is testing.
Possible solutions
Beta Was this translation helpful? Give feedback.
All reactions