Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Bug fix: Can not attach SnappingSheetController #63 #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Bug fix: Can not attach SnappingSheetController #63 #74

wants to merge 1 commit into from

Conversation

akbarpulatov
Copy link

import 'package:flutter/material.dart';
import 'package:snapping_sheet/snapping_sheet.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {

    SnappingSheetController snappingSheetController = SnappingSheetController();
    return Scaffold(
      appBar: AppBar(

        title: Text(widget.title),
      ),
      body: SnappingSheet(
        // Connect it to the SnappingSheet
        controller: snappingSheetController,

        grabbingHeight: 200,
        grabbing: GestureDetector(
          onTap: (){
            print('Controller is working now!');
            snappingSheetController.snapToPosition(
              SnappingPosition.factor(positionFactor: 0.75),
            );
          },
          child: Container(
              height: 200,
              color: Colors.blue
          ),
        ),
        sheetBelow: SnappingSheetContent(
          draggable: true,
          child: Container(color: Colors.red),
        ),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

@akbarpulatov
Copy link
Author

Bug fix: Can not attach SnappingSheetController #63

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant