Last active
January 5, 2024 15:40
-
-
Save pmatatias/5983c0a339626820d56fa71e32ab3d96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
title: 'Demo', | |
home: HomeLayout(), | |
); | |
} | |
} | |
class HomeLayout extends StatelessWidget { | |
const HomeLayout({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return const Scaffold( | |
body: SafeArea( | |
child: Row( | |
children: [ | |
Expanded(flex: 30, child: LeftWidget()), | |
Expanded(flex: 60, child: RightWidget()), | |
], | |
), | |
), | |
); | |
} | |
} | |
class LeftWidget extends StatelessWidget { | |
const LeftWidget({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Material( | |
elevation: 1, | |
color: Colors.blueGrey.shade100, | |
child: const Center( | |
child: Text( | |
"Left Widget", | |
style: TextStyle(fontSize: 24), | |
), | |
), | |
); | |
} | |
} | |
class RightWidget extends StatefulWidget { | |
const RightWidget({ | |
super.key, | |
}); | |
@override | |
State<RightWidget> createState() => _RightWidgetState(); | |
} | |
class _RightWidgetState extends State<RightWidget> { | |
double items = 0; | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: [ | |
Slider( | |
value: items, | |
onChanged: (item) => setState(() { | |
items = item; | |
})), | |
Expanded( | |
child: ListView.builder( | |
itemCount: (items * 20).toInt(), | |
itemBuilder: (context, index) => Dismissible( | |
key: UniqueKey(), | |
direction: DismissDirection.endToStart, | |
child: Card( | |
color: Colors.amber.shade100, | |
child: Padding( | |
padding: const EdgeInsets.all(18.0), | |
child: Text(index.toString()), | |
), | |
), | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment