Flutter fade animation between page views - flutter

I'm trying to find how to fade between PageView pages.
This is my pageView:
PageView(
controller: controller,
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/image4.jpg"),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/image2.jpg"),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/image3.jpg"),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
],
),
Is it possible to implement a fade transition? I searched stack overflow but the only thing I could find was this package:
https://pub.dev/packages/transformer_page_view#-readme-tab-
The problem is that it hasn't a controller so my smoothPageIndactor wouldn't work. (https://pub.dev/packages/smooth_page_indicator)
Thanks!

You can copy paste run full code below
You can use TransformerPageView.children and TransformerPageController
TransformerPageController controller = TransformerPageController();
...
Expanded(
flex: 5,
child: TransformerPageView.children(
pageController: controller,
transformer: ScaleAndFadeTransformer(),
working demo
full code
import 'package:flutter/material.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:transformer_page_view/transformer_page_view.dart';
class ScaleAndFadeTransformer extends PageTransformer {
final double _scale;
final double _fade;
ScaleAndFadeTransformer({double fade: 0.3, double scale: 0.8})
: _fade = fade,
_scale = scale;
#override
Widget transform(Widget item, TransformInfo info) {
double position = info.position;
double scaleFactor = (1 - position.abs()) * (1 - _scale);
double fadeFactor = (1 - position.abs()) * (1 - _fade);
double opacity = _fade + fadeFactor;
double scale = _scale + scaleFactor;
return new Opacity(
opacity: opacity,
child: new Transform.scale(
scale: scale,
child: item,
),
);
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
TransformerPageController controller = TransformerPageController();
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
flex: 5,
child: TransformerPageView.children(
pageController: controller,
transformer: ScaleAndFadeTransformer(),
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image:
NetworkImage('https://picsum.photos/250?image=9'),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://picsum.photos/250?image=10'),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
'https://picsum.photos/250?image=11'),
fit: BoxFit.cover),
),
child: Center(
child: Text(
'myText',
style: TextStyle(color: Colors.white, fontSize: 40.0),
)),
),
],
),
),
Expanded(
flex: 1,
child: SmoothPageIndicator(
controller: controller, // PageController
count: 3,
effect: WormEffect(), // your preferred effect
),
)
],
),
),
);
}
}

You can use AnimatedSwitcher as the body of your main widget:
AnimatedSwitcher(
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(
child: child,
opacity: animation,
);
},
duration: const Duration(milliseconds: 600),
child: _widgetOptions.elementAt(_selectedIndex))

Related

How Can i set same position of widgets for different device?

Hi to Everyone. I am setting position of icon widget. But it is
changing on different device. How can i fix it? thanks in advance.
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[for example][1]
import 'package:flutter/material.dart';
import 'package:country_icons/country_icons.dart';
class E_Takvim_Container extends StatefulWidget {
const E_Takvim_Container({Key key}) : super(key: key);
#override
_E_Takvim_ContainerState createState() => _E_Takvim_ContainerState();
}
class _E_Takvim_ContainerState extends State<E_Takvim_Container> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Takvim"),
backgroundColor: Colors.amber,
),
body: IntrinsicHeight(
child: Container(
child: Column(
children: [
Card(
child: Row(
children: [
Container(
width: 30,
height: 30,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'icons/flags/png/de.png',
package: 'country_icons',
),
),
borderRadius:
BorderRadius.all(Radius.elliptical(300, 900))),
),
Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
Padding(
padding: const EdgeInsets.only(left:100.0),
child: Icon(Icons.arrow_forward_ios),
)
],
),
),
],
),
),
),
);
}
}
[1]: https://i.stack.imgur.com/nIzkv.png
For your code example, you can use Expanded for your TextView widget.
Expanded(
flex: 1,
child: Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
)
If you want to get the same results at different screen resolutions, (for example: size of widgets or font sizes) You can take a look at the package: ScreenUtils

In the bottom of my app there is a white space Flutter

import 'package:flutter/material.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:url_launcher/url_launcher.dart';
class HomeScreen extends StatefulWidget {
#override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
int _currentIndex = 0;
List cardList = [Item1(), Item2(), Item3(), Item4()];
List<T> map<T>(List list, Function handler) {
List<T> result = [];
for (var i = 0; i < list.length; i++) {
result.add(handler(i, list[i]));
}
return result;
}
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Card Carousel App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: SafeArea(
child: Scaffold(
resizeToAvoidBottomPadding: false,
appBar: AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image(
image: AssetImage('assets/liberta.jpeg'),
width: 120,
),
Text(
'Libertà&Ricchezza',
style: TextStyle(color: Colors.black),
)
],
),
backgroundColor: Colors.white,
),
body: SingleChildScrollView(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
image: DecorationImage(
image: AssetImage('assets/background.jpeg'),
fit: BoxFit.cover,
)
),
child: Column(
children: <Widget>[
SizedBox(
height: 10,
),
CarouselSlider(
options: CarouselOptions(
height: 240.0,
autoPlay: true,
autoPlayInterval: Duration(seconds: 3),
autoPlayAnimationDuration: Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
pauseAutoPlayOnTouch: true,
aspectRatio: 2.0,
onPageChanged: (index, reason) {
setState(() {
_currentIndex = index;
});
},
),
items: cardList.map((card) {
return Builder(builder: (BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height * 0.30,
width: MediaQuery.of(context).size.width,
child: Card(
color: Colors.blueAccent,
child: card,
),
);
});
}).toList(),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: map<Widget>(cardList, (index, url) {
return Container(
width: 10.0,
height: 10.0,
margin:
EdgeInsets.symmetric(vertical: 10.0, horizontal: 2.0),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _currentIndex == index
? Colors.white
: Colors.grey,
),
);
}),
),
SizedBox(
height: 20,
),
Row(
children: [
Expanded(
child: Container(
height: 85,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Color(0xff024f9c),
),
child: Center(
child: Text(
"L&R PER LA PERSONA",
style: TextStyle(
color: Colors.white,
fontSize:20,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
),
)),
],
),
Row(
children: [
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
Navigator.pushNamed(context, '/persona');
});
},
child: Container(
height: 85,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Color(0xff9c0202),
),
child: Center(
child: Text(
"L&R PER L'AZIENDA",
style: TextStyle(
color: Colors.white,
fontSize:20,
fontWeight: FontWeight.bold
),
textAlign: TextAlign.center,
),
),
)),
),
],
)
],
),
),
),
),
));
}
}
class Item1 extends StatelessWidget {
const Item1({Key key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
child: InkWell(
child: Image(
image: AssetImage('assets/mandela.jpeg'),
fit: BoxFit.cover,
),
onTap: () => launch('https://www.instagram.com/libertaericchezza/'),
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [
0.3,
1
],
colors: [
Color(0xffff4000),
Color(0xffffcc66),
]),
),
);
}
}
class Item2 extends StatelessWidget {
const Item2({Key key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
child:InkWell(
child: Image(
image: AssetImage('assets/astronauta.jpeg'),
fit: BoxFit.cover,
),
onTap: () => launch('https://www.instagram.com/libertaericchezza/'),
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [
0.3,
1
],
colors: [
Color(0xffff4000),
Color(0xffffcc66),
]),
),
);
}
}
class Item3 extends StatelessWidget {
const Item3({Key key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
child:InkWell(
child: Image(
image: AssetImage('assets/farfalle.jpeg'),
fit: BoxFit.cover,
),
onTap: () => launch('https://www.instagram.com/libertaericchezza/'),
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [
0.3,
1
],
colors: [
Color(0xffff4000),
Color(0xffffcc66),
]),
),
);
}
}
class Item4 extends StatelessWidget {
const Item4({Key key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
child: InkWell(
child: Image(
image: AssetImage('assets/car.jpeg'),
fit: BoxFit.cover,
),
onTap: () => launch('https://www.instagram.com/libertaericchezza/'),
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [
0.3,
1
],
colors: [
Color(0xffff4000),
Color(0xffffcc66),
]),
),
);
}
}
I have insert a background image but there is a white space on the bottom and i don-t understand why, i try the resizedToAVoidBottomPadding but doesn-t work,I have insert a background image but there is a white space on the bottom and i don-t understand why, i try the resizedToAVoidBottomPadding but doesn-t workI have insert a background image but there is a white space on the bottom and i don-t understand why, i try the resizedToAVoidBottomPadding but doesn-t work
Have you try remove bottom safearea, safearea will occupy both top and bottom for notch and control area:
SafeArea(
bottom: false,

How to download network image in Flutter

I am building a simple wallpaper app with Api by watching tutorials on YouTube. But in the last stage, I can't save the image from the URL in the android simulator. Can you guys help me with how can I do this work?
import 'package:flutter/material.dart';
class ImageView extends StatefulWidget {
final String imageUrl;
ImageView({#required this.imageUrl});
#override
_ImageViewState createState() => _ImageViewState();}
class _ImageViewState extends State<ImageView> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Hero(
tag: widget.imageUrl,
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Image.network(
widget.imageUrl,
fit: BoxFit.cover,
),
),
),
//the buttons is here
Container(
alignment: Alignment.bottomCenter,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
//wallpaper download button
GestureDetector(
onTap: () {},
child: Stack(
children: [
Container(
height: 55,
width: MediaQuery.of(context).size.width / 2,
decoration: BoxDecoration(
color: Color(0xff1c1b1b).withOpacity(0.8),
borderRadius: BorderRadius.circular(30),
)),
Container(
padding:
EdgeInsets.symmetric(horizontal: 8, vertical: 8),
width: MediaQuery.of(context).size.width / 2,
height: 55,
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 1,
),
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(colors: [
Colors.blueGrey[100],
Colors.grey[900],
])),
child: Column(
children: [
Text(
'Set Wallpaper',
style: TextStyle(
fontSize: 16,
color: Colors.white,
),
),
SizedBox(height: 5),
Text(
'Image wil be save in gallery',
style: TextStyle(
fontSize: 10,
color: Colors.white,
),
)
],
)),
],
),
),
SizedBox(height: 16),
//for closeing the showing wallpaper
GestureDetector(
onTap: () => Navigator.pop(context),
child: Text(
'Cancel',
style: TextStyle(
color: Colors.amber,
),
),
),
SizedBox(height: 50)
],
),
)
],
),
);
}
}
You can copy paste run full code below
Step 1: To save image to gallery, add <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> to AndroidManifest.xml
Step 2: Request permission with permission_handler
Step 3: Download file with flutter_cache_manager's DefaultCacheManager().getSingleFile(widget.imageUrl)
Step 4: Save to gallery with image_gallery_saver's ImageGallerySaver.saveFile(file.path)
Step 5: Directly set wall paper with wallpaper_manager's WallpaperManager.setWallpaperFromFile(file.path, WallpaperManager.HOME_SCREEN)
code snippet
_requestPermission() async {
Map<Permission, PermissionStatus> statuses = await [
Permission.storage,
].request();
final info = statuses[Permission.storage].toString();
print(info);
}
...
GestureDetector(
onTap: () async {
File file = await DefaultCacheManager()
.getSingleFile(widget.imageUrl);
print(file.path);
final result = await ImageGallerySaver.saveFile(file.path);
print("gallerysaver result $result");
String resultWall =
await WallpaperManager.setWallpaperFromFile(
file.path, WallpaperManager.HOME_SCREEN);
print("resultWall $resultWall");
},
working demo
full code
import 'dart:io';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:wallpaper_manager/wallpaper_manager.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
class ImageView extends StatefulWidget {
final String imageUrl;
ImageView({#required this.imageUrl});
#override
_ImageViewState createState() => _ImageViewState();
}
class _ImageViewState extends State<ImageView> {
#override
void initState() {
super.initState();
_requestPermission();
}
_requestPermission() async {
Map<Permission, PermissionStatus> statuses = await [
Permission.storage,
].request();
final info = statuses[Permission.storage].toString();
print(info);
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Hero(
tag: widget.imageUrl,
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Image.network(
widget.imageUrl,
fit: BoxFit.cover,
),
),
),
//the buttons is here
Container(
alignment: Alignment.bottomCenter,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
//wallpaper download button
GestureDetector(
onTap: () async {
File file = await DefaultCacheManager()
.getSingleFile(widget.imageUrl);
print(file.path);
final result = await ImageGallerySaver.saveFile(file.path);
print("gallerysaver result $result");
String resultWall =
await WallpaperManager.setWallpaperFromFile(
file.path, WallpaperManager.HOME_SCREEN);
print("resultWall $resultWall");
},
child: Stack(
children: [
Container(
height: 55,
width: MediaQuery.of(context).size.width / 2,
decoration: BoxDecoration(
color: Color(0xff1c1b1b).withOpacity(0.8),
borderRadius: BorderRadius.circular(30),
)),
Container(
padding:
EdgeInsets.symmetric(horizontal: 8, vertical: 8),
width: MediaQuery.of(context).size.width / 2,
height: 55,
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 1,
),
borderRadius: BorderRadius.circular(30),
gradient: LinearGradient(colors: [
Colors.blueGrey[100],
Colors.grey[900],
])),
child: Column(
children: [
Text(
'Set Wallpaper',
style: TextStyle(
fontSize: 16,
color: Colors.white,
),
),
SizedBox(height: 5),
Text(
'Image wil be save in gallery',
style: TextStyle(
fontSize: 10,
color: Colors.white,
),
)
],
)),
],
),
),
SizedBox(height: 16),
//for closeing the showing wallpaper
GestureDetector(
onTap: () => Navigator.pop(context),
child: Text(
'Cancel',
style: TextStyle(
color: Colors.amber,
),
),
),
SizedBox(height: 50)
],
),
)
],
),
);
}
}
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ImageView(
imageUrl: "https://picsum.photos/250?image=9")),
);
},
child: Text('To set wall paper')),
])));
}
}

Flutter: How to specify the location of a text?

So, I'm wanting to add a text below an image of the application I'm doing. However, the text seems to be appearing beside the image, not below as per so:
I want it to appear below the image like the screenshot below:
This is my main.dart code:
import 'package:flutter/material.dart';
import 'login_page.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return new MaterialApp(
home: new LoginPage(),
theme: new ThemeData(
primarySwatch: Colors.green
)
);
}
}
And this is my login_page.dart code:
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget{
#override
State createState() => new LoginPageState();
}
class LoginPageState extends State<LoginPage>{
#override
Widget build(BuildContext context){
return new Scaffold(
appBar: AppBar(
title: new Text("SMARTID", textAlign: TextAlign.center, style: TextStyle(fontFamily: 'Open Sans', fontWeight: FontWeight.bold)),
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
"assets/arrowPNG.png",
scale: 8.0,
)
)
),
backgroundColor: Colors.transparent,
body: new Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('assets/arrowPNG.png', scale: 2.5),
]
),
alignment: Alignment(0, -0.5),
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/background.png'),
fit: BoxFit.cover,
)
)
)
);
}
}
How do I resolve this?
Here is your solution,
You should place Text("SMARTID")
below Image.asset
inside a Column not in a Row
class LoginState extends State<Login> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("SMARTID", textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Open Sans', fontWeight: FontWeight.bold)),
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
"assets/images/appicon.png",
scale: 8.0,
)
)
),
backgroundColor: Colors.transparent,
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('assets/images/appicon.png', scale: 2.5),
SizedBox(height: 20,),
Text("SMARTID", style: TextStyle(
fontSize: 30, color: Colors.white,fontFamily: 'Open Sans',
fontWeight: FontWeight.bold))
]
),
alignment: Alignment(0, -0.5),
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/background.jpg'),
fit: BoxFit.cover,
)
)
)
);
}
}
Output,

How to add a draggable "textfield" to add text over images in flutter?

I am creating a Meme generator application in flutter..i just need to know is there a way that user itself can add text over image and drag that text anywhere in the image area...so that the picture would look funny .I tried dragbox widget but dont know how can i use that for textfield..so that i too can move my text anywhere on the image.I need something like this
class TextOverImage extends StatelessWidget {
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Text Over Image Image Example'),
),
body: Center(
child: Container(
height: 300,
width: 300,
child: Stack(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Colors.blue,
image: DecorationImage(
image: new NetworkImage(
"https://thumbs.dreamstime.com/b/funny-face-baby-27701492.jpg"),
fit: BoxFit.fill)),
),
HomePage()
],
),
),
),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Offset offset = Offset.zero;
#override
Widget build(BuildContext context) {
return Container(
child: Positioned(
left: offset.dx,
top: offset.dy,
child: GestureDetector(
onPanUpdate: (details) {
setState(() {
offset = Offset(
offset.dx + details.delta.dx, offset.dy + details.delta.dy);
});
},
child: SizedBox(
width: 300,
height: 300,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Text("You Think You Are Funny But You Are Not",
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 28.0,
color: Colors.red)),
),
),
)),
),
);
}
}