Skip to content

Instantly share code, notes, and snippets.

@Andrious
Created June 7, 2019 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrious/6cbf703d3254625d37545b59dd845ecc to your computer and use it in GitHub Desktop.
Save Andrious/6cbf703d3254625d37545b59dd845ecc to your computer and use it in GitHub Desktop.
Multiple Scaffold's. Some with primary: false
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
home: MyApp()
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Primary true. Thick AppBar')),
primary: true,
floatingActionButton: FloatingActionButton(
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => NotPrimary())),
tooltip: 'Increment Counter',
child: Icon(Icons.arrow_forward),
));
}
}
class NotPrimary extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
primary: false,
appBar: AppBar(title: Text('Primary is false. Thin AppBar')),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => WithKeyboard(),
));
},
),
);
}
}
class WithKeyboard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
primary: true,
// Deprecated, use resizeToAvoidBottomInset instead.
resizeToAvoidBottomPadding: false,
// resizeToAvoidBottomInset: false,
appBar: AppBar(title: Text('Primary true. Thicker AppBar again.')),
body: Form(
child: ListView(
children: List.generate(10, (index) {
if (index == 6)
return TextFormField(
initialValue: "This line is always visible.");
if (index == 9)
return TextFormField(
initialValue:
"This line goes behind the keyboard. Click here and see.");
return TextFormField();
}).toList(),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment