2017-10-06 19 views

答えて

0

Scaffoldには右から左にスワイプするendDrawerプロパティが追加されました。

これは誰かを助けるかもしれないと思っています。

1

あなたはそれがあるかどうか、あなたのアプリケーションの右バー/メニューやDrawerを表示しようとしている場合は、永久的なビューまたは一時的なものを持っています。 AllignContainerColumnウィジェットから独自のカスタムウィジェットを作成し、setStateを使用してユーザーの操作に基づいてメニューバーを表示または非表示にすることで、これを実現できました。

enter image description here

マイカスタムメニューウィジェットは、以下のようになります。

class RightNavigationBar extends StatefulWidget { 
    @override 
    _RightNavigationBarState createState() => new _RightNavigationBarState(); 
} 

class _RightNavigationBarState extends State<RightNavigationBar> { 
    @override 
    Widget build(BuildContext context) { 
    return new Align(
     alignment: FractionalOffset.centerRight, 
     child: new Container(
     child: new Column(
      children: <Widget>[ 
      new Icon(Icons.navigate_next), 
      new Icon(Icons.close), 
      new Text ("More items..") 
      ], 
     ), 
     color: Colors.blueGrey, 
     height: 700.0, 
     width: 200.0, 
    ), 
    ); 
    } 
} 

ユーザーがメニューiconを押したときに、私のカスタムRightNavigationBarウィジェットのオブジェクトがsetState内に作成されます。

class MyApp extends StatefulWidget { 
    @override 
    _MyAppState createState() => new _MyAppState(); 
} 

class _MyAppState extends State<MyApp> { 
    var _myRightBar = null; 

    @override 
    Widget build(BuildContext context) { 
    return new Scaffold(
     appBar: new AppBar(
      actions: [new IconButton(
       icon: new Icon (Icons.menu), onPressed: _showRightBar) 
      ], 
      title: new Text("Right Navigation Bar Example"), 
     ), 
     body: _myRightBar 

    ); 
    } 

    _showRightBar() { 
    setState(() { 
     _myRightBar == null 
      ? _myRightBar = new RightNavigationBar() 
      : _myRightBar = null; 
    }); 
    } 
} 
関連する問題