Skip to content

Instantly share code, notes, and snippets.

@rubywai
Created May 3, 2023 17:12
Show Gist options
  • Select an option

  • Save rubywai/f4dbaabbe3c97db33f55854c5d811d84 to your computer and use it in GitHub Desktop.

Select an option

Save rubywai/f4dbaabbe3c97db33f55854c5d811d84 to your computer and use it in GitHub Desktop.
//debug release profile
//assets file binary network
//container
// Material , Cupertino
//Stateless .Stateful
//row column wrap container stack
//listview gridview
import 'package:flutter/material.dart';
//asset file network memory
void main() {
runApp(const MaterialApp(debugShowCheckedModeBanner: false, home: Home()));
}
//List ListView.builder() ListView.separeate()
class Home extends StatelessWidget {
const Home({Key? key}) : super(key: key);
//positioned
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Stack Lesson'),
),
body: GridView.builder(
padding: EdgeInsets.all(8),
itemCount: 1000,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 8,
crossAxisSpacing: 8,
childAspectRatio: 2/3
),
itemBuilder: (BuildContext context, int index) {
return Container(
padding: const EdgeInsets.all(3),
color: Colors.grey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Person $index'),
const Divider(color: Colors.white,),
const Icon(Icons.person),
const Divider(color: Colors.white,),
ElevatedButton(onPressed: (){
_showSnackBar(context, "You followed Person $index");
}, child: const Text('Follow'))
],
),
);
},
)
);
}
Widget _profile(BuildContext context,int position){
debugPrint('ui is building $position');
return Column(
children: [
ListTile(
onTap: (){
_showSnackBar(context, 'Person $position');
},
leading: const Icon(Icons.person),
title: Text('Person $position'),
subtitle: Text('Address $position'),
trailing: (position %2 == 0) ? const Icon(Icons.phone) : const Icon(Icons.email),
),
const Divider(height: 4,thickness: 3,),
],
);
}
void _showSnackBar(BuildContext context,String text){
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(text)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment