Кликабельные тексты на моей странице с фоновым изображением - PullRequest
0 голосов
/ 03 февраля 2020

У меня проблема, на моей странице я хочу кликнуть некоторые тексты, которые я использую над фоновым изображением, я даже использую InkWell и GestureDetector, но оба они не работают, я использую их для фонового изображения, но они не работает, я не знаю, как я решаю, плз, помогите мне

Widget build(BuildContext context) {
return new Scaffold(

  body: new Stack(
    children: <Widget>[

        Image.asset('images/mainUiNew.jpg',
         height: MediaQuery.of(context).size.height,
         width: double.infinity,
         fit:  BoxFit.cover,
         alignment: Alignment.center,),

      new Align(
        alignment: Alignment(-0.58, -0.7),
        child: new InkWell(
          child: new Text('Tracking',style: StyleTitle() ),
          onTap: () {
            print('hi');
          },
        ),
      ),

     new Align(
        alignment: Alignment(-0.49, -0.55),
        child: new InkWell(
          child: new Text('Track & Trace Your Package',style: StyleSubtitle()),
          onTap: () {
            var Router = new MaterialPageRoute(builder: (BuildContext){
              return new CustomLoginForm();
            });
            Navigator.of(context).push(Router);
          },
        ),
      ),
      new Align(
        alignment: Alignment(0.1,-0.1),
        child: new InkWell(
          child: new Text('OutBound',style: StyleTitle()),
          onTap: (){
            var Router = new MaterialPageRoute(builder: (BuildContext){
              return new OutBoundRate();
            });
            Navigator.of(context).push(Router);
          },
        ),
      ),
      new Align(
          alignment: Alignment(0.3, 0.02),
          child: new InkWell(
            child: new Text('Get OutBound Package Rate ',style: StyleSubtitle()),
            onTap: (){
              var Router = new MaterialPageRoute(builder: (BuildContext){
                return new OutBoundRate();
              });
              Navigator.of(context).push(Router);
            },
          )

      ),
      new Align(
          alignment: Alignment(-0.58,0.6),
          child: new InkWell(
            child: new Text('InBound',style: StyleTitle()),
            onTap: (){
              var Router = new MaterialPageRoute(builder: (BuildContext){
                return new InBoundRate();
              });
              Navigator.of(context).push(Router);
            },
          )
      ),
      new Align(
          alignment: Alignment(-0.49, 0.7),
          child: new InkWell(
            child: new Text('Get InBound Package Rate ',style:StyleSubtitle()),
            onTap: (){
              var Router = new MaterialPageRoute(builder: (BuildContext){
                return new InBoundRate();
              });
              Navigator.of(context).push(Router);
            },
          )

      ),
      new ListView.builder(
        itemBuilder: (BuildContext context, int index) {
          return new ExpandableListView(title: "Main Menu");
        },
        itemCount: 1,
      ),
    ],
  ),
  floatingActionButton: Container(
    height: 100.0,
    width: 100.0,
    decoration: BoxDecoration(
      borderRadius: new BorderRadius.all(
          Radius.circular(60.0)),
        boxShadow: <BoxShadow>[
          BoxShadow(

              color: Colors.black54,
              blurRadius: 10.0,
              offset: Offset(0.0, 0.75)
          )
        ],
        color: Colors.white,
    ),

    child: FittedBox(
      child: FloatingActionButton(


        backgroundColor: Color(0xffffcd05),
          child: Padding(

            padding: const EdgeInsets.all(4.0),
            child: Image.asset("images/logo-express.png",height:200.0,width: 300.0,

            ),
          ),
          onPressed: () {
            var Router = new MaterialPageRoute(builder: (BuildContext){
              return new FirstPage();
            });
            Navigator.of(context).push(Router);
          }),

    ),
   //shape:
   //        icon: new Icon(Icons.add,
   //        color: Color(0xffd4351c),),

   // shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(100.0),)),
   // child: Image.asset("images/logo-express.png",height:200.0,width: 400.0,),

  ),
  floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  bottomNavigationBar: BottomAppBar(
    //clipBehavior:Clip.antiAlias,
    color: Color(0xffd4351c),
     //shape: CircularNotchedRectangle(),
    child: new Row(
      mainAxisSize: MainAxisSize.min,
      //mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      children: <Widget>[
         //SizedBox(width: double.infinity, height: 70.0,),
        Material(
          child: SizedBox(
           // width: double.infinity,
            height: 60.0,),
          color: Color(0xffd4351c),
        ),
       // SizedBox(),
        FlatButton.icon(onPressed: (){
          Navigator.push(context, SlideRightRoute(page: ContactUs()));
        },
          icon: Icon(Icons.phone_in_talk,color:Colors.white,),
          label: new Text('Contact Us',style: TextStyle(color: Colors.white),),
          padding: EdgeInsets.fromLTRB(10.0, 0, 0, 0),),

        FlatButton.icon(onPressed: (){
          Navigator.push(context, SlideLeftRoute(page: AboutUs()));
        },
          icon: Icon(Icons.person,color: Colors.white,),
          label: new Text('About US',style: TextStyle(color: Colors.white),),
          padding: EdgeInsets.fromLTRB(200, 0 , 0.0, 0),),
      ],

    )
  ),
);
}

Ответы [ 3 ]

0 голосов
/ 03 февраля 2020

, если вы хотите использовать стек:

return Scaffold(
   body: Container(
     width: MediaQuery.of(context).size.width,
     height: MediaQuery.of(context).size.height,
     child: Stack(
       children: <Widget>[
        *your children here*
       ]
     )
   )
);

, но я предлагаю использовать это:

return Scaffold(
   body: Container(
     width: MediaQuery.of(context).size.width,
     height: MediaQuery.of(context).size.height,
     decoration: BoxDecoration(
       image: DecorationImage(
         image: NetworkImage(*image_url*) or you can use AssetImage(*asset_path*),
         fit: BoxFit.cover
       )
     ),
     child: Row/Column(
        children: <Widget>[
           *your children here*
        ]
     )
   )
);
0 голосов
/ 03 февраля 2020

Мне нужно было shrinkWrap = true внутри ListView.builder.

В противном случае дети не будут знать, сколько места занимает прокручиваемый виджет.

0 голосов
/ 03 февраля 2020

Используя стек, вы должны использовать позиционированный виджет вместо выравнивания и использовать жест-детектор. Для детектора жестов используйте следующий код:

GestureDetector(
  onTap: () {
    print("onTap called.");
  },
  child: Text("foo"),
),

будет работать вместо чернильницы.

...