Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Scope SnackBars for nested Scaffolds in demo #377

Merged
merged 6 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions lib/codeviewer/code_segments.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37180,20 +37180,6 @@ class CodeSegments {
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.punctuationStyle, text: '{'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a '),
TextSpan(style: codeStyle.keywordStyle, text: 'final'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'GlobalKey'),
TextSpan(style: codeStyle.punctuationStyle, text: '<'),
TextSpan(style: codeStyle.classStyle, text: 'ScaffoldState'),
TextSpan(style: codeStyle.punctuationStyle, text: '>'),
TextSpan(style: codeStyle.baseStyle, text: ' _scaffoldKey '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'GlobalKey'),
TextSpan(style: codeStyle.punctuationStyle, text: '<'),
TextSpan(style: codeStyle.classStyle, text: 'ScaffoldState'),
TextSpan(style: codeStyle.punctuationStyle, text: '>();'),
TextSpan(style: codeStyle.baseStyle, text: '\u000a\u000a '),
TextSpan(style: codeStyle.classStyle, text: 'PersonData'),
TextSpan(style: codeStyle.baseStyle, text: ' person '),
TextSpan(style: codeStyle.punctuationStyle, text: '='),
Expand Down Expand Up @@ -37619,10 +37605,6 @@ class CodeSegments {
TextSpan(style: codeStyle.baseStyle, text: ' '),
TextSpan(style: codeStyle.classStyle, text: 'Scaffold'),
TextSpan(style: codeStyle.punctuationStyle, text: '('),
TextSpan(style: codeStyle.baseStyle, text: '\u000a key'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' _scaffoldKey'),
TextSpan(style: codeStyle.punctuationStyle, text: ','),
TextSpan(style: codeStyle.baseStyle, text: '\u000a body'),
TextSpan(style: codeStyle.punctuationStyle, text: ':'),
TextSpan(style: codeStyle.baseStyle, text: ' '),
Expand Down
3 changes: 0 additions & 3 deletions lib/demos/material/menu_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class MenuDemo extends StatefulWidget {
}

class _MenuDemoState extends State<MenuDemo> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

void showInSnackBar(String value) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
Expand All @@ -64,7 +62,6 @@ class _MenuDemoState extends State<MenuDemo> {
}

return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text(GalleryLocalizations.of(context).demoMenuTitle),
automaticallyImplyLeading: false,
Expand Down
3 changes: 0 additions & 3 deletions lib/demos/material/text_field_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class _PasswordFieldState extends State<PasswordField> {
}

class TextFormFieldDemoState extends State<TextFormFieldDemo> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

PersonData person = PersonData();

void showInSnackBar(String value) {
Expand Down Expand Up @@ -172,7 +170,6 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
const sizedBoxSpace = SizedBox(height: 24);

return Scaffold(
key: _scaffoldKey,
body: Form(
key: _formKey,
autovalidateMode: _autoValidateMode,
Expand Down
13 changes: 8 additions & 5 deletions lib/pages/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ class _DemoPageState extends State<DemoPage> {
// Return to root if invalid slug.
Navigator.of(context).pop();
}
return GalleryDemoPage(
return ScaffoldMessenger(
child: GalleryDemoPage(
restorationId: widget.slug,
demo: slugToDemoMap[widget.slug],
);
));
}
}

Expand Down Expand Up @@ -382,9 +383,11 @@ class _GalleryDemoPageState extends State<GalleryDemoPage>
}

Widget body;
Widget demoContent = DemoContent(
height: contentHeight,
buildRoute: _currentConfig.buildRoute,
Widget demoContent = ScaffoldMessenger(
child: DemoContent(
height: contentHeight,
buildRoute: _currentConfig.buildRoute,
),
);
if (isDesktop) {
final isFullScreen = currentDemoState == _DemoState.fullscreen;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.0"
version: "5.5.0"
watcher:
dependency: transitive
description:
Expand Down