four_swipe_direction 0.0.4 four_swipe_direction: ^0.0.4 copied to clipboard
A new Flutter package project.
import 'package:flutter/material.dart';
import 'package:four_swipe_direction/four_swipe_direction.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Center(
child: FourSwipeDirection(
swipeUp: () {
print('上');
},
swipeDown: (){
print('下');
},
swipeLeft: () {
print('左');
},
swipeRight: () {
print('右');
},
child: Container(
color: Colors.indigo,
width: 100,
height: 100,
),
),
),
),
);
}
}