dashstrap_button 1.0.0 dashstrap_button: ^1.0.0 copied to clipboard
A new Flutter package project.
import 'package:dashstrap_button/dashstrap_button.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
enum AllButtons {
defaultButton,
small,
normal,
large,
smallIcon,
normalIcon,
largeIcon,
smallDisabled,
normalDisabled,
largeDisabled,
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: ListView.separated(
padding: EdgeInsets.only(
top: 48,
),
itemBuilder: (_, index) {
AllButtons button = AllButtons.values[index];
return Center(
child: getButton(button),
);
},
separatorBuilder: (_, __) {
return Padding(
padding: EdgeInsets.only(
top: 32,
),
);
},
itemCount: AllButtons.values.length,
),
),
);
}
Widget getButton(AllButtons buttonType) {
switch (buttonType) {
case AllButtons.defaultButton:
return DSButton(
text: "Default Button",
);
case AllButtons.small:
return DSButton(
text: "Small button",
size: DSButtonSize.small,
);
case AllButtons.normal:
return DSButton(
text: "Normal button",
size: DSButtonSize.normal,
);
case AllButtons.large:
return DSButton(
text: "Large button",
size: DSButtonSize.large,
);
case AllButtons.smallIcon:
return DSButton(
text: "Small Icon button",
size: DSButtonSize.small,
icon: Icons.email,
);
case AllButtons.normalIcon:
return DSButton(
text: "Normal Icon button",
size: DSButtonSize.normal,
icon: Icons.email,
);
case AllButtons.largeIcon:
return DSButton(
text: "Large Icon button",
size: DSButtonSize.large,
icon: Icons.email,
);
case AllButtons.smallDisabled:
return DSButton(
text: "Small button disabled",
size: DSButtonSize.small,
disabled: true,
);
case AllButtons.normalDisabled:
return DSButton(
text: "Normal button disabled",
size: DSButtonSize.normal,
disabled: true,
);
case AllButtons.largeDisabled:
return DSButton(
text: "Large button disabled",
size: DSButtonSize.large,
disabled: true,
);
default:
return Container(
height: 0,
width: 0,
);
}
}
}