Skip to content

Instantly share code, notes, and snippets.

@Rahiche
Created August 11, 2018 14:02
Show Gist options
  • Save Rahiche/26ebe328cc0365de6fa125d83ed59b4d to your computer and use it in GitHub Desktop.
Save Rahiche/26ebe328cc0365de6fa125d83ed59b4d to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
theme: ThemeData(primaryColor: Colors.tealAccent), home: new MyApp()));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double sliderValue = 1.0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.teal,
appBar: AppBar(
title: Slider(
activeColor: Colors.red,
min: 1.0,
max: 3.0,
onChanged: (double value) {
setState(() {
sliderValue = value;
});
print(sliderValue);
},
value: sliderValue,
),
),
body: GridView.count(
crossAxisCount: sliderValue.toInt(),
childAspectRatio: 16.0 / (sliderValue * 10.0),
children: <Widget>[
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
Card(child: Center(child: Text("DATA"))),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment