4

Is it possible to set SafeArea once for every route? For now I have no idea how to do that nor found such question. Do I have to put it every screen view?

0

3 Answers 3

4

You can copy paste run full code below
You can use builder of MaterialApp

code snippet

MaterialApp( title: 'Builder Demo', builder: (BuildContext context, Widget child) { return SafeArea( child: child, ); }, 

full code

import 'package:flutter/material.dart'; void main() { runApp(MaterialApp( title: 'Builder Demo', builder: (BuildContext context, Widget child) { return SafeArea( child: child, ); }, initialRoute: '/', routes: { '/': (context) => FirstScreen(), '/second': (context) => SecondScreen(), }, )); } class FirstScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('First Screen'), ), body: Center( child: RaisedButton( child: Text('Launch screen'), onPressed: () { // Navigate to the second screen using a named route. Navigator.pushNamed(context, '/second'); }, ), ), ); } } class SecondScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Second Screen"), ), body: Center( child: RaisedButton( onPressed: () { // Navigate back to the first screen by popping the current route // off the stack. Navigator.pop(context); }, child: Text('Go back!'), ), ), ); } } 
Sign up to request clarification or add additional context in comments.

Comments

1

I had to add scaffold widget as child of safearea because it complained about widget parameter being nullable...

builder: (context, widget) { return SafeArea( child: Scaffold( body: widget, ), ); }, 

Comments

0

Apart from all these changes mentioned in doc: https://pub.dev/packages/just_audio_background

I needed MainActivity to extend AudioServiceActivity and also neede MediaTag() to those audios that need to be played in background

await _audioPlayer.setAudioSource( AudioSource.asset( "assets/audio/db12/$currentKey.wav", tag: MediaItem( id: currentKey, album: "album", title: "title", artist: "flutter jackson", ), ), ); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.