Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 views
in Technique[技术] by (71.8m points)

flutter - How to create a widget that stays alive on all screens? Like spotify's miniplayer

I'm currently building a podcast app and what I want to implement is something similar to miniplayer in Spotify.

When user taps on a podcast and start listening, I want to open a miniplayer and make it alive across on all pages.

First thing come up to my mind is using Overlay widget or using a custom navigator for all of the pages and put that navigator inside a stack. I wonder if anyone implement something like this before or what's the best way to approach this.

spotify miniplayer

question from:https://stackoverflow.com/questions/65870603/how-to-create-a-widget-that-stays-alive-on-all-screens-like-spotifys-miniplaye

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would recommend using this with a Stack. Maybe something like this:

class PodcastApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: [
          Expanded(
            child: Stack(
              children: [
                SizedBox.expand(child: PageView()),
                Align(
                  alignment: Alignment.bottomCenter,
                  child: YOUR_MINI_PLAYER(),
                )
              ],
            ),
          ),
          BottomNavigationBar(),
        ],
      ),
    );
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...