Advertisement
Guest User

flutter_shine_neumorphic.dart

a guest
Jan 21st, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.87 KB | None | 0 0
  1. import 'dart:math';
  2.  
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_shine/flutter_shine.dart';
  5.  
  6. void main() => runApp(MyApp());
  7.  
  8. class MyApp extends StatefulWidget {
  9.   @override
  10.   _MyAppState createState() => _MyAppState();
  11. }
  12.  
  13. class _MyAppState extends State<MyApp> {
  14.   double x;
  15.   double y;
  16.  
  17.   @override
  18.   void initState() {
  19.     super.initState();
  20.  
  21.     x = -100;
  22.     y = -100;
  23.   }
  24.  
  25.   @override
  26.   Widget build(BuildContext context) {
  27.     final backColour = Colors.grey[400];
  28.     final Config configDark = Config(shadowColor: Colors.grey[800]);
  29.     final Config configLight = Config(shadowColor: Colors.white.withOpacity(0.8));
  30.     return MaterialApp(
  31.       home: Scaffold(
  32.         backgroundColor: backColour,
  33.         appBar: AppBar(
  34.           title: const Text('Shine'),
  35.         ),
  36.         body: GestureDetector(
  37.           onLongPressMoveUpdate: _onLongPressMoveUpdate,
  38.           child: Stack(
  39.             children: [
  40.               FlutterShine(
  41.                 config: configDark,
  42.                 light: Light(intensity: 0.5, position: Point(x, y)),
  43.                 builder: (BuildContext context, ShineShadow shineShadow) {
  44.                   return Column(
  45.                     crossAxisAlignment: CrossAxisAlignment.center,
  46.                     mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  47.                     mainAxisSize: MainAxisSize.max,
  48.                     children: <Widget>[
  49.                       Text(
  50.                         "Shine",
  51.                         style: TextStyle(
  52.                             fontSize: 130,
  53.                             color: backColour,
  54.                             shadows: shineShadow?.shadows),
  55.                       ),
  56.                     ],
  57.                   );
  58.                 },
  59.               ),
  60.               FlutterShine(
  61.                 config: configLight,
  62.                 light: Light(intensity: 0.5, position: Point(-x, -y)),
  63.                 builder: (BuildContext context, ShineShadow shineShadow) {
  64.                   return Column(
  65.                     crossAxisAlignment: CrossAxisAlignment.center,
  66.                     mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  67.                     mainAxisSize: MainAxisSize.max,
  68.                     children: <Widget>[
  69.                       Text(
  70.                         "Shine",
  71.                         style: TextStyle(
  72.                             fontSize: 130,
  73.                             color: backColour,
  74.                             shadows: shineShadow?.shadows),
  75.                       ),
  76.                     ],
  77.                   );
  78.                 },
  79.               ),
  80.             ],
  81.           ),
  82.         ),
  83.       ),
  84.     );
  85.   }
  86.  
  87.   void _onLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
  88.     setState(() {
  89.       this.x = details.offsetFromOrigin.dx;
  90.       this.y = details.offsetFromOrigin.dy;
  91.     });
  92.   }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement