Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast displayed on main page only #18

Closed
xihuny opened this issue Apr 17, 2019 · 4 comments
Closed

Toast displayed on main page only #18

xihuny opened this issue Apr 17, 2019 · 4 comments

Comments

@xihuny
Copy link

xihuny commented Apr 17, 2019

I have multiple pages in my app. The problem is Toast is showing only on the main page, even if I call showToastWidget(...) from any other pages. Please have a look at my code below

Page 1 - Main Page

  Widget build(BuildContext context) {
    return OKToast(
      child: Scaffold(
        backgroundColor: Theme.of(context).accentColor,
        body: Center(
          child: SizedBox(
            height: 50,
            width: 50,
            child: Image(image: AssetImage('assets/ic_logo.png')),
          ),
        ),
      ),
    );
  }```

**Page 2**
```  @override
  Widget build(BuildContext context) {
    return OKToast(
      child: Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: Text('Page2'),
        ),
        body: ...
);```
@CaiJingLong
Copy link
Member

See Readme

You don't need to wrap Scaffold of every page, you just need to wrap your MaterialApp.(WidgetsApp or CupertinoApp).

@CaiJingLong
Copy link
Member

CaiJingLong commented Apr 17, 2019

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return OKToast(
//2. wrap your app with OKToast
textStyle: TextStyle(fontSize: 19.0, color: Colors.white),
backgroundColor: Colors.grey,
radius: 10.0,
child: new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
),
);
}
}

@xihuny
Copy link
Author

xihuny commented Apr 17, 2019

Yes. My mistake. I wasn't editing the main.dart file

@dotcink
Copy link

dotcink commented Apr 15, 2020

See Readme

You don't need to wrap Scaffold of every page, you just need to wrap your MaterialApp.(WidgetsApp or CupertinoApp).

However, with this, Image.asset()will be unable to use 2x 3x images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants