flutter_neumorphism 0.0.2 copy "flutter_neumorphism: ^0.0.2" to clipboard
flutter_neumorphism: ^0.0.2 copied to clipboard

A Flutter package for building beautiful Neumorphic UI components with soft shadows and modern design aesthetics.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_neumorphism/flutter_neumorphism.dart';
import 'package:flutter_neumorphism/neumorphism_theme/light_source.dart';

import 'main_home.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return NeumorphismApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      themeMode: ThemeMode.light,
      theme: NeumorphismThemeData(
        baseColor: Color(0xFFFFFFFF),
        lightSource: LightSource.topLeft,
        depth: 10,
      ),
      darkTheme: NeumorphismThemeData(
        baseColor: Color(0xFF3E3E3E),
        lightSource: LightSource.topLeft,
        depth: 6,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key});

  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: NeumorphismFloatingActionButton(
        child: Icon(Icons.add, size: 30),
        onPressed: () {},
      ),
      backgroundColor: NeumorphismTheme.baseColor(context),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            NeumorphismButton(
              onPressed: () {
                print("onClick");
              },
              style: NeumorphismStyle(
                shape: NeumorphismShape.flat,
                boxShape: NeumorphismBoxShape.circle(),
              ),
              padding: const EdgeInsets.all(12.0),
              child: Icon(
                Icons.favorite_border,
                color: _iconsColor(context),
              ),
            ),
            NeumorphismButton(
                margin: EdgeInsets.only(top: 12),
                onPressed: () {
                  NeumorphismTheme.of(context)?.themeMode =
                      NeumorphismTheme.isUsingDark(context)
                          ? ThemeMode.light
                          : ThemeMode.dark;
                },
                style: NeumorphismStyle(
                  shape: NeumorphismShape.flat,
                  boxShape:
                      NeumorphismBoxShape.roundRect(BorderRadius.circular(8)),
                ),
                padding: const EdgeInsets.all(12.0),
                child: Text(
                  "Toggle Theme",
                  style: TextStyle(color: _textColor(context)),
                )),
            NeumorphismButton(
                margin: EdgeInsets.only(top: 12),
                onPressed: () {
                  Navigator.of(context)
                      .pushReplacement(MaterialPageRoute(builder: (context) {
                    return FullSampleHomePage();
                  }));
                },
                style: NeumorphismStyle(
                  shape: NeumorphismShape.flat,
                  boxShape:
                      NeumorphismBoxShape.roundRect(BorderRadius.circular(8)),
                  //border: NeumorphismBorder()
                ),
                padding: const EdgeInsets.all(12.0),
                child: Text(
                  "Go to full sample",
                  style: TextStyle(color: _textColor(context)),
                )),
          ],
        ),
      ),
    );
  }

  Color? _iconsColor(BuildContext context) {
    final theme = NeumorphismTheme.of(context);
    if (theme!.isUsingDark) {
      return theme.current!.accentColor;
    } else {
      return null;
    }
  }

  Color _textColor(BuildContext context) {
    if (NeumorphismTheme.isUsingDark(context)) {
      return Colors.white;
    } else {
      return Colors.black;
    }
  }
}
3
likes
55
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for building beautiful Neumorphic UI components with soft shadows and modern design aesthetics.

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on flutter_neumorphism