0

I want to open new page when I swipe the circle in the middle of the screen. that is when I swipe blue circle left a new page should open and when I swipe right another new page should open.

Similarly when I swipe pink circle bottom another new page should open

Here is my code:

import 'package:flutter/material.dart';

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          height: 300.0,
          width: 150.0,
          child: Stack(
            children: <Widget>[
              Positioned(
                top: 25,
                  child: Container(
                  height: 150.0,
                  width: 150.0,
                  decoration: BoxDecoration(
                    shape:BoxShape.circle,
                    color:Colors.lightBlue,
                  ),
                ),
              ),
              Positioned(
                bottom: 25,
                child: Opacity(
                  opacity: 0.45,
                    child: Container(
                    height: 150.0,
                  width: 150.0,
                  decoration: BoxDecoration(
                    shape:BoxShape.circle,
                    color:Colors.pinkAccent,
                  ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Bilaal Abdel Hassan
  • 1,181
  • 2
  • 12
  • 20

1 Answers1

0

wrap Positioned() with SwipeDetector() Widget

Have a look at this example

    SwipeDetector(
     onSwipeRight: () {
       //push new page
       Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context) => new YourNewPage())); 
      },
     child: //Your circle here
            Positioned(
                top: 25,
                  child: Container(
                  height: 150.0,
                  width: 150.0,
                  decoration: BoxDecoration(
                    shape:BoxShape.circle,
                    color:Colors.lightBlue,
                  ),
                ),
              ),
         )
Bilaal Abdel Hassan
  • 1,181
  • 2
  • 12
  • 20