Skip to content

Instantly share code, notes, and snippets.

@rena2019
Created May 26, 2026 14:24
Show Gist options
  • Select an option

  • Save rena2019/789df722b4098c983b78c5971746ff52 to your computer and use it in GitHub Desktop.

Select an option

Save rena2019/789df722b4098c983b78c5971746ff52 to your computer and use it in GitHub Desktop.
shadow + scrollview test
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Schatten + Scroll (variabel)',
home: const Scaffold(
body: SafeArea(
child: ShadowAndScrollExample(itemCount: 15), // Anzahl hier setzen
),
),
);
}
}
class ShadowAndScrollExample extends StatelessWidget {
final int itemCount;
const ShadowAndScrollExample({super.key, this.itemCount = 15});
@override
Widget build(BuildContext context) {
return Column(
children: [
ConstrainedBox(
constraints: BoxConstraints(
minHeight: 100,
maxHeight: 100,
minWidth: 800,
maxWidth: 800,
),
child: Container(
width: 800,
height: 100,
decoration: BoxDecoration(
color: Colors.yellow.shade100,
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 20,
spreadRadius: 5,
),
],
),
),
),
/*
Stack(
//clipBehavior: Clip.none, // wichtig: erlaubt Überhang
children: [
Positioned(
left: 0,
top: 0,
child: Container(
width: 800,
height: 100,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 20,
spreadRadius: 5,
),
],
),
),
),
],
)),*/
/*
// Widget mit 10 Pixel Schatten
Container(
margin: const EdgeInsets.all(16),
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.25),
blurRadius: 10, // 10 Pixel Schatten
offset: const Offset(0, 4),
),
],
),
child: const Center(
child: Text(
'Widget mit 10px Schatten',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
),
),
), */
// Scrollbarer Bereich mit variabler Anzahl großer Text-Widgets
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(
itemCount,
(index) => Padding(
padding: const EdgeInsets.only(bottom: 24, top: 8),
child: Text(
'Großer Text ${index + 1}',
style: const TextStyle(fontSize: 32),
),
),
),
),
),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment