Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:math';
- import 'package:flutter/material.dart';
- import 'package:flutter_shine/flutter_shine.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatefulWidget {
- @override
- _MyAppState createState() => _MyAppState();
- }
- class _MyAppState extends State<MyApp> {
- double x;
- double y;
- @override
- void initState() {
- super.initState();
- x = -100;
- y = -100;
- }
- @override
- Widget build(BuildContext context) {
- final backColour = Colors.grey[400];
- final Config configDark = Config(shadowColor: Colors.grey[800]);
- final Config configLight = Config(shadowColor: Colors.white.withOpacity(0.8));
- return MaterialApp(
- home: Scaffold(
- backgroundColor: backColour,
- appBar: AppBar(
- title: const Text('Shine'),
- ),
- body: GestureDetector(
- onLongPressMoveUpdate: _onLongPressMoveUpdate,
- child: Stack(
- children: [
- FlutterShine(
- config: configDark,
- light: Light(intensity: 0.5, position: Point(x, y)),
- builder: (BuildContext context, ShineShadow shineShadow) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- mainAxisSize: MainAxisSize.max,
- children: <Widget>[
- Text(
- "Shine",
- style: TextStyle(
- fontSize: 130,
- color: backColour,
- shadows: shineShadow?.shadows),
- ),
- ],
- );
- },
- ),
- FlutterShine(
- config: configLight,
- light: Light(intensity: 0.5, position: Point(-x, -y)),
- builder: (BuildContext context, ShineShadow shineShadow) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- mainAxisSize: MainAxisSize.max,
- children: <Widget>[
- Text(
- "Shine",
- style: TextStyle(
- fontSize: 130,
- color: backColour,
- shadows: shineShadow?.shadows),
- ),
- ],
- );
- },
- ),
- ],
- ),
- ),
- ),
- );
- }
- void _onLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
- setState(() {
- this.x = details.offsetFromOrigin.dx;
- this.y = details.offsetFromOrigin.dy;
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement