Last active
January 11, 2025 14:36
-
-
Save wemgl/784f4435c7491cfba3b5f994545d521a to your computer and use it in GitHub Desktop.
stackoverflow_question_solution_74152502
This file contains hidden or 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 'dart:math'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MainApp()); | |
} | |
class MainApp extends StatelessWidget { | |
const MainApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: SafeArea( | |
child: CustomScrollView( | |
slivers: <Widget>[ | |
const SliverToBoxAdapter( | |
child: Align( | |
alignment: Alignment.centerLeft, | |
child: Padding( | |
padding: EdgeInsets.all(16.0), | |
child: SizedBox(height: 16.0, child: Text("Some Title")), | |
), | |
), | |
), | |
SliverGrid.builder( | |
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( | |
maxCrossAxisExtent: 120, | |
), | |
itemBuilder: (context, index) { | |
return Container( | |
color: _randomColor(), | |
); | |
}, | |
itemCount: 100, | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
Color _randomColor() { | |
final index = Random().nextInt(Colors.primaries.length); | |
return Colors.primaries[index]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment