Skip to content

Instantly share code, notes, and snippets.

@csells
Last active September 7, 2021 20:17
Show Gist options
  • Select an option

  • Save csells/563366310b0445fcfbf9b1664589792d to your computer and use it in GitHub Desktop.

Select an option

Save csells/563366310b0445fcfbf9b1664589792d to your computer and use it in GitHub Desktop.
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('The MaterialBanner is below'),
),
body: Center(
child: ElevatedButton(
child: const Text('Show MaterialBanner'),
onPressed: () => ScaffoldMessenger.of(context).showMaterialBanner(
MaterialBanner(
content: const Text('Hello, I am a Material Banner'),
leading: const Icon(Icons.info),
backgroundColor: Colors.yellow,
actions: [
TextButton(
child: const Text('Dismiss'),
onPressed: () => ScaffoldMessenger.of(context)
.hideCurrentMaterialBanner(),
),
],
),
),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment