Created
June 7, 2019 17:58
-
-
Save Andrious/6cbf703d3254625d37545b59dd845ecc to your computer and use it in GitHub Desktop.
Multiple Scaffold's. Some with primary: false
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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