Untitled
unknown
plain_text
2 months ago
2.5 kB
4
Indexable
import 'package:flutter/material.dart'; void main() { runApp(RootWidget()); } class homePage extends StatefulWidget { const homePage({super.key}); @override State<homePage> createState() => _homePageState(); } class _homePageState extends State<homePage> { // Stateful function int counter = 0; void incrementCounter(){ // for incrementing counter setState(() { // Allow for automatic rendering counter++; }); } @override Widget build(BuildContext context) { return Scaffold( // Scaffold is reflected as one page appBar: AppBar( backgroundColor: Colors.amberAccent, title: Text("@gon_creates"), ), body: Center( child: Column( children: [ Row( children: [ Container( height: 100, width: 100, padding: const EdgeInsets.all(20.0), child: ClipOval(child: Image.asset("assets/pic.png"),), ), Column( children: [ Text("Gon Creates", style: TextStyle(color: Colors.amberAccent),), ] ) ], ), Expanded(child: mySubjects()), ], ), ), backgroundColor: const Color.fromARGB(255, 57, 57, 57), floatingActionButton: FloatingActionButton( onPressed: incrementCounter, child: Icon(Icons.add), ), // Func that doesn't do anything ); } } class RootWidget extends StatelessWidget { const RootWidget({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: homePage() ); } } Widget mySubjects() { List<String> subjects = [ "CMSC 12", "CMSC 21", "CMSC 22", "CMSC 23", "CMSC 100" ]; return GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3), itemCount: subjects.length, itemBuilder: (BuildContext context, int index) { return Card( color: Colors.pink, child: Center(child: Text("${subjects[index]}")), ); }); }
Editor is loading...
Leave a Comment