J'ai un peu de problèmes avec le tiroir, j'ai cherché sur la pile une solution pour cela, et j'ai trouvé une solution, mais après l'avoir essayé, cela ne fonctionnait pas pour moi! :) L'idée est que je veux avoir des articles dans des tiroirs affichés à la toute fin de la fin! :)
Drawer( child: Container( decoration: BoxDecoration(color: Color(0xFF0098c2)), child: ListView( children: <Widget>[ ListTile( title: Text( 'Dealer', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.person, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => dealerBuilder())); }, ), ListTile( title: Text( 'Shuffler', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.shuffle, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => shufflerBuilder())); }, ), ListTile( title: Text( 'Mistakes', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.info_outline, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => mistakePage())); }, ), ListTile( title: Text( 'Important links', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.border_color, size: 20.0, color: Colors.white, ), onTap: () { Navigator.of(context).push(new MaterialPageRoute( builder: (context) => importantLinks())); }, ), Container( child: Align( alignment: FractionalOffset.bottomCenter, child: Column( children: <Widget>[ Divider(), ListTile( leading: Icon(Icons.settings), title: Text('Facebook')), ListTile( leading: Icon(Icons.help), title: Text('Instagram')) ], ))), ], ), ), ),
3 Réponses :
Essayez ceci:
Drawer( child: Container( decoration: BoxDecoration(color: Color(0xFF0098c2)), child: ListView( children: <Widget>[ ListTile( title: Text( 'Dealer', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.person, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => dealerBuilder())); }, ), ListTile( title: Text( 'Shuffler', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.shuffle, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => shufflerBuilder())); }, ), ListTile( title: Text( 'Mistakes', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.info_outline, size: 20.0, color: Colors.white, ), onTap: () { Navigator.pop(context); Navigator.of(context).push(new MaterialPageRoute( builder: (context) => mistakePage())); }, ), ListTile( title: Text( 'Important links', style: TextStyle(fontSize: 18.0, color: Colors.white), ), leading: Icon( Icons.border_color, size: 20.0, color: Colors.white, ), onTap: () { Navigator.of(context).push(new MaterialPageRoute( builder: (context) => importantLinks())); }, ), Expanded(), Container( child: Align( alignment: FractionalOffset.bottomCenter, child: Column( children: <Widget>[ Divider(), ListTile( leading: Icon(Icons.settings), title: Text('Facebook')), ListTile( leading: Icon(Icons.help), title: Text('Instagram')) ], ))), ], ), ), ),
Cela ne fonctionnera pas car il ne fonctionnera pas comme étant élargi d'essayer de prendre autant d'espace que possible et de la répertorie pour lui donner une hauteur infinie.
Voici un moyen de le faire
à l'aide de résultat d'image: strong>
p> Code de test complet utilisé strong> p> LayoutAbuilder code>,
Contraindbox Code> et
intransichétight CODE> Vous allez pouvoir utiliser
développé code> même dans un ScrollView et gardez votre page de page d'image en bas. Il vous permet d'avoir une mise en page réactive sur n'importe quel écran de téléphone. P>
Vous pouvez copier Coller Run Code complet ci-dessous Démo de travail P > Code complet P>
Vous pouvez remplacer listview code> avec
colonne code> et envelopper le premier groupe avec
colonne expansé code>
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
drawer: Drawer(
child: Container(
decoration: BoxDecoration(color: Color(0xFF0098c2)),
child: Column(
children: <Widget>[
Expanded(
child: Column(children: <Widget>[
ListTile(
title: Text(
'Dealer',
style: TextStyle(fontSize: 18.0, color: Colors.white),
),
leading: Icon(
Icons.person,
size: 20.0,
color: Colors.white,
),
onTap: () {
/* Navigator.pop(context);
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => dealerBuilder()));*/
},
),
ListTile(
title: Text(
'Shuffler',
style: TextStyle(fontSize: 18.0, color: Colors.white),
),
leading: Icon(
Icons.shuffle,
size: 20.0,
color: Colors.white,
),
onTap: () {
/*Navigator.pop(context);
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => shufflerBuilder()));*/
},
),
ListTile(
title: Text(
'Mistakes',
style: TextStyle(fontSize: 18.0, color: Colors.white),
),
leading: Icon(
Icons.info_outline,
size: 20.0,
color: Colors.white,
),
onTap: () {
/* Navigator.pop(context);
Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => mistakePage()));*/
},
),
ListTile(
title: Text(
'Important links',
style: TextStyle(fontSize: 18.0, color: Colors.white),
),
leading: Icon(
Icons.border_color,
size: 20.0,
color: Colors.white,
),
onTap: () {
/*Navigator.of(context).push(new MaterialPageRoute(
builder: (context) => importantLinks()));*/
},
),
]),
),
Container(
child: Align(
alignment: FractionalOffset.bottomCenter,
child: Column(
children: <Widget>[
Divider(),
ListTile(
leading: Icon(Icons.settings),
title: Text('Facebook')),
ListTile(
leading: Icon(Icons.help),
title: Text('Instagram'))
],
))),
],
),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
),
);
}
}
Votre solution est bonne mais ce n'est pas complètement réactif. Selon la taille de l'écran de téléphone et le numéro de listtile code>, vous pouvez obtenir un débordement.