|
1 | 1 | # flutter_poplayer
|
2 | 2 |
|
3 |
| -A new Flutter package project. |
| 3 | +Left slide and slide up drawer effect. Compatible with Android & iOS. |
4 | 4 |
|
5 |
| -## Getting Started |
| 5 | +### Installation |
6 | 6 |
|
7 |
| -This project is a starting point for a Dart |
8 |
| -[package](https://flutter.dev/developing-packages/), |
9 |
| -a library module containing code that can be shared easily across |
10 |
| -multiple Flutter or Dart projects. |
| 7 | +Add |
11 | 8 |
|
12 |
| -For help getting started with Flutter, view our |
13 |
| -[online documentation](https://flutter.dev/docs), which offers tutorials, |
14 |
| -samples, guidance on mobile development, and a full API reference. |
| 9 | +```bash |
| 10 | + |
| 11 | +flutter_swiper : ^lastest_version |
| 12 | + |
| 13 | +``` |
| 14 | +to your pubspec.yaml ,and run |
| 15 | + |
| 16 | +```bash |
| 17 | +flutter packages get |
| 18 | +``` |
| 19 | +in your project's root directory. |
| 20 | + |
| 21 | +### Basic Usage |
| 22 | + |
| 23 | +Create a new project with command |
| 24 | + |
| 25 | +``` |
| 26 | +flutter create myapp |
| 27 | +``` |
| 28 | + |
| 29 | +Edit lib/main.dart like this: |
| 30 | + |
| 31 | +``` |
| 32 | +
|
| 33 | +import 'package:flutter/material.dart'; |
| 34 | +
|
| 35 | +import 'package:flutter_poplayer/flutter_poplayer.dart'; |
| 36 | +
|
| 37 | +void main() => runApp(MyApp()); |
| 38 | +
|
| 39 | +class MyApp extends StatelessWidget { |
| 40 | + // This widget is the root of your application. |
| 41 | + @override |
| 42 | + Widget build(BuildContext context) { |
| 43 | + return MaterialApp( |
| 44 | + title: 'flutter_poplayer demo', |
| 45 | + theme: ThemeData( |
| 46 | + primarySwatch: Colors.blue, |
| 47 | + ), |
| 48 | + home: MyHomePage(title: 'Flutter Demo Home Page'), |
| 49 | + ); |
| 50 | + } |
| 51 | +} |
| 52 | +
|
| 53 | +class MyHomePage extends StatefulWidget { |
| 54 | + MyHomePage({Key key, this.title}) : super(key: key); |
| 55 | +
|
| 56 | + final String title; |
| 57 | +
|
| 58 | + @override |
| 59 | + _MyHomePageState createState() => _MyHomePageState(); |
| 60 | +} |
| 61 | +
|
| 62 | +class _MyHomePageState extends State<MyHomePage> { |
| 63 | + RightPopConfig _rightPopConfig; |
| 64 | + TopPopConfig _topPopConfig; |
| 65 | + final PoplayerController _controller = PoplayerController(); |
| 66 | + @override |
| 67 | + void initState() { |
| 68 | + super.initState(); |
| 69 | + _rightPopConfig = RightPopConfig( |
| 70 | + needRight: true, |
| 71 | + maxWidth: 240, |
| 72 | + backgroupColor: Colors.yellow, |
| 73 | + autoAnimDistance: 20, |
| 74 | + container: GestureDetector( |
| 75 | + child: Center(child: Text('点我收起')), |
| 76 | + onTap: () { |
| 77 | + _controller.autoToRight(); |
| 78 | + }, |
| 79 | + )); |
| 80 | +
|
| 81 | + _topPopConfig = TopPopConfig( |
| 82 | + backgroupColor: Colors.red, |
| 83 | + needTop: true, |
| 84 | + topMaxHeight: 740, |
| 85 | + topAutoAnimDistance: 20, |
| 86 | + topMinHeight: 150, |
| 87 | + container: GestureDetector( |
| 88 | + child: Center(child: Text('点我收起')), |
| 89 | + onTap: () { |
| 90 | + _controller.autoToBottom(); |
| 91 | + }, |
| 92 | + )); |
| 93 | + } |
| 94 | +
|
| 95 | + @override |
| 96 | + Widget build(BuildContext context) { |
| 97 | + return Scaffold( |
| 98 | + appBar: AppBar( |
| 99 | + title: Text(widget.title), |
| 100 | + ), |
| 101 | + body: Poplayer( |
| 102 | + rightPopConfig: _rightPopConfig, |
| 103 | + topPopConfig: _topPopConfig, |
| 104 | + controller: _controller, |
| 105 | + content: Container( |
| 106 | + child: Center( |
| 107 | + child: Text('content'), |
| 108 | + ), |
| 109 | + ), |
| 110 | + ), |
| 111 | + ); |
| 112 | + } |
| 113 | +} |
| 114 | +
|
| 115 | +``` |
15 | 116 |
|
0 commit comments