text stringlengths 1 372 |
|---|
final string name; |
final string uid; |
final ImageProvider imageProvider; |
string get formattedTotalItemPrice => |
'\$${(totalpricecents / 100.0).tostringasfixed(2)}'; |
} |
class customer { |
customer({ |
required this.name, |
required this.imageProvider, |
List<Item>? items, |
}) : items = items ?? []; |
final string name; |
final ImageProvider imageProvider; |
final List<Item> items; |
string get formattedTotalItemPrice { |
final totalPriceCents = |
items.fold<int>(0, (prev, item) => prev + item.totalPriceCents); |
return '\$${(totalpricecents / 100.0).tostringasfixed(2)}'; |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
add material touch ripples |
widgets that follow the material design guidelines display |
a ripple animation when tapped. |
flutter provides the InkWell |
widget to perform this effect. |
create a ripple effect using the following steps: |
<code_start> |
// the InkWell wraps the custom flat button widget. |
InkWell( |
// when the user taps the button, show a snackbar. |
onTap: () { |
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( |
content: Text('Tap'), |
)); |
}, |
child: const padding( |
padding: EdgeInsets.all(12), |
child: Text('Flat button'), |
), |
) |
<code_end> |
<topic_end> |
<topic_start> |
interactive example |
<code_start> |
import 'package:flutter/material.dart'; |
void main() => runApp(const MyApp()); |
class MyApp extends StatelessWidget { |
const MyApp({super.key}); |
@override |
widget build(BuildContext context) { |
const title = 'inkwell demo'; |
return const MaterialApp( |
title: title, |
home: MyHomePage(title: title), |
); |
} |
} |
class MyHomePage extends StatelessWidget { |
final string title; |
const MyHomePage({super.key, required this.title}); |
@override |
widget build(BuildContext context) { |
return scaffold( |
appBar: AppBar( |
title: text(title), |
), |
body: const center( |
child: MyButton(), |
), |
); |
} |
} |
class MyButton extends StatelessWidget { |
const MyButton({super.key}); |
@override |
widget build(BuildContext context) { |
// the InkWell wraps the custom flat button widget. |
return InkWell( |
// when the user taps the button, show a snackbar. |
onTap: () { |
ScaffoldMessenger.of(context).showSnackBar(const SnackBar( |
content: Text('Tap'), |
)); |
}, |
child: const padding( |
padding: EdgeInsets.all(12), |
child: Text('Flat button'), |
), |
); |
} |
} |
<code_end> |
<topic_end> |
<topic_start> |
implement swipe to dismiss |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.