相关疑难解决方法(0)

在颤动中处理滚动方向

我有一个虚拟的项目列表,我想在向上滑动的方向上显示一个浮动操作按钮并在向下的方向上隐藏它。我怎样才能实现这个功能?

class _MyHomePageState extends State<MyHomePage> {
  bool upDirection = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Container(
          child: Row(
            children: <Widget>[
              Expanded(
                  child: ListView.builder(
                    itemCount: 100,
                    itemBuilder: (context,index){
                      return ListTile(
                        title: Text(index.toString()),
                      );
                    },
                  ),
              )
            ],
          ),
        ),
      ),
      floatingActionButton:upDirection==true?FloatingActionButton(onPressed: (){},):Container() ,
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

dart flutter

9
推荐指数
1
解决办法
7066
查看次数

检测在颤动中向右滑动

香港专业教育学院尝试使用swipedetector插件进行颤动,以实现向右滑动的新屏幕的导航,但无法正常工作,不会引发任何错误,并且在调试时永远不会碰到断点。我查看了GestureDector,但不确定是否可以在向右滑动的Scenerio中使用它,我们希望在向右滑动屏幕时可以将其导航到屏幕。

这是我使用插件的代码

 @override
 Widget build(BuildContext context){
return new Scaffold(
 appBar : LBAppBar().getAppBar(),
  //drawer: new LBDrawer().getDrawer(),
 body:  Container(
decoration: BoxDecoration(
    gradient: new LinearGradient(
        colors: [Color.fromRGBO(1,89,99, 1.0), Colors.grey],
        begin: Alignment.bottomLeft,
        end: Alignment.topRight
    )
),
 child: 
 SwipeDetector(
     onSwipeRight: () {
       Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context) => new WidgetsPage())
        ); },
  child: Column(
  mainAxisAlignment: MainAxisAlignment.center,    
  children:[
    Row(
            children: [
          Container(
            margin: EdgeInsets.only(left: 20.0,top: 10.0, bottom: 10.0, right:30.0),
            child: Column(
  children: <Widget>[



            Text("Hi ${user.firstName}, Today is " + formatDate(), style: new TextStyle( color: Colors.white70, fontWeight: FontWeight.bold, …
Run Code Online (Sandbox Code Playgroud)

dart flutter

3
推荐指数
7
解决办法
2784
查看次数

标签 统计

dart ×2

flutter ×2