custom drawer

import 'package:flutter/material.dart';

main() => runApp(MaterialApp(
  home: HomePage(),
));

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return HomePageState();
  }
}

class HomePageState extends State<HomePage> {
  double w, h;
  double page;
  double draw = 0.0;
  double i = 50;
  bool ini = true;

  @override
  Widget build(BuildContext context) {
    w = MediaQuery.of(context).size.width;
    h = MediaQuery.of(context).size.height;

    if(ini) {
      page = w;
      ini = !ini;
    }

    return SafeArea(
      child: Scaffold(
        body: Container(
          width: w, height: h,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Container(color: Colors.black, width: draw,),
              Container(
                width: page,
                child: SingleChildScrollView(
                    scrollDirection: Axis.horizontal,
                    child: Container(color: Colors.amberAccent,child: Text('atest'),)),
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(onPressed: (){
          setState(() {
            draw = w * 3/5;
            page = w * 2/5;
          });
        }),
      ),
    );
  }
}

  

猜你喜欢

转载自www.cnblogs.com/pythonClub/p/11022927.html